Ai
21 Star 49 Fork 0

Gitee 极速下载/julia-language

加入 Gitee
与超过 1200万 开发者一起发现、参与优秀开源项目,私有仓库也完全免费 :)
免费加入
文件
此仓库是为了提升国内下载速度的镜像仓库,每日同步一次。 原始仓库: https://github.com/JuliaLang/julia
克隆/下载
ImmutableArrays.jl 1.10 KB
一键复制 编辑 原始数据 按行查看 历史
Jishnu Bhattacharya 提交于 2023-12-20 20:42 +08:00 . invperm for immutable arrays (#52546)
# 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
Loading...
马建仓 AI 助手
尝试更多
代码解读
代码找茬
代码优化
C++
1
https://gitee.com/mirrors/julia-language.git
git@gitee.com:mirrors/julia-language.git
mirrors
julia-language
julia-language
master

搜索帮助