/
githubmirror
/
julia
Обзор
Документация
Войти
/
githubmirror
/
julia
Код
Запросы
0
Пакеты
0
Релизы
0
Аналитика
Безопасность
master
test/testhelpers/ImmutableArrays.jl
31 строка
1 KB
Jishnu Bhattacharya
`invperm` for immutable arrays (#52546)
20 дек 2023, 15:42
Не верифицирован
20 дек 2023, 15:42
f8cd1eb
Код
Авторство
О чём код?
# This file is a part of Julia. License is MIT: https://julialang.org/license # ImmutableArrays (arrays that implement getindex but not setindex!) # This test file defines an array wrapper that is immutable. It can be used to # test the action of methods on immutable arrays. module ImmutableArrays export ImmutableArray "An immutable wrapper type for arrays." struct ImmutableArray{T,N,A<:AbstractArray} <: AbstractArray{T,N} data::A end ImmutableArray(data::AbstractArray{T,N}) where {T,N} = ImmutableArray{T,N,typeof(data)}(data) # Minimal AbstractArray interface Base.size(A::ImmutableArray) = size(A.data) Base.size(A::ImmutableArray, d) = size(A.data, d) Base.getindex(A::ImmutableArray, i...) = getindex(A.data, i...) # The immutable array remains immutable after conversion to AbstractArray AbstractArray{T}(A::ImmutableArray) where {T} = ImmutableArray(AbstractArray{T}(A.data)) AbstractArray{T,N}(A::ImmutableArray{S,N}) where {S,T,N} = ImmutableArray(AbstractArray{T,N}(A.data)) Base.copy(A::ImmutableArray) = ImmutableArray(copy(A.data)) Base.zero(A::ImmutableArray) = ImmutableArray(zero(A.data)) end