Reference
Index
FixedSizeArrays.FixedSizeArrayFixedSizeArrays.FixedSizeArrayDefaultFixedSizeArrays.FixedSizeArrayDimsFixedSizeArrays.FixedSizeMatrixFixedSizeArrays.FixedSizeMatrixDefaultFixedSizeArrays.FixedSizeVectorFixedSizeArrays.FixedSizeVectorDefaultBase.parentFixedSizeArrays.static_dimsFixedSizeArrays.with_stripped_type_parametersFixedSizeArrays.with_stripped_type_parameters_uncheckedFixedSizeArrays.wrap
Public API
FixedSizeArrays.FixedSizeArray — Type
FixedSizeArray{T,N,Mem<:DenseVector{T}}(undef, size::NTuple{N,Int})
FixedSizeArray{T,N,Mem<:DenseVector{T}}(undef, size1::Int, size2::Int, ...)
FixedSizeArray{T,N,Mem<:DenseVector{T}}(array::AbstractArray)Construct a fixed-size FixedSizeArray with element type T, number of dimensions N, and memory backend Mem.
Convenient aliases provided:
FixedSizeVector{T,Mem}: for 1-dimensional fixed-size arraysFixedSizeMatrix{T,Mem}: for 2-dimensional fixed-size arraysFixedSizeArrayDefault{T,N}: forN-dimensional fixed-size arrays, with default memory backendFixedSizeVectorDefault{T}: for 1-dimensional fixed-size arrays, with default memory backendFixedSizeMatrixDefault{T}: for 2-dimensional fixed-size arrays, with default memory backend
Static dimensions
FixedSizeArray{T,N,Mem} is an alias for FixedSizeArrayDims{T,N,NTuple{N,Int},Mem}: the dimensions of a FixedSizeArrayDims{T,N,D,Mem} are a tuple dims::D of Ints, Vals and StaticInts from Static.jl. Each dimension can be dynamic, i.e. an Int stored in the array, or static, i.e. a compile-time constant which is part of the type D and takes no space in the array. E.g. with dims = (Val(5), Val(4), n), D = Tuple{Val{5}, Val{4}, Int}, or with dims = (static(5), static(4), n), D = Tuple{StaticInt{5}, StaticInt{4}, Int}, the array has size (5, 4, n), and n can be different for different arrays of the same type. Static.jl is a weak dependency: load it (e.g. with using Static: static) to use StaticInt dimensions, while Val dimensions need no other package.
The static dimensions allow the compiler to compute the linear indices, the strides, and the sizes in these dimensions at compile time, which is useful e.g. for arrays where some dimensions are fixed (variables, nodes, ...) while others (elements of a mesh, particles, ...) change at runtime. An array with static dimensions is constructed with the FixedSizeArrayDims constructors, with collect_as, or with FixedSizeArrays.wrap around an existing memory backend.
The dimensions given to a constructor are converted to the dimensions type of the array, if its type gives it: e.g. FixedSizeArray{T}(undef, (Val(2), 3)) has two dynamic dimensions, while FixedSizeArrayDims{T}(undef, (Val(2), 3)) has a static one.
Examples
julia> using FixedSizeArraysjulia> using FixedSizeArrays: FixedSizeArrayDimsjulia> a = FixedSizeArray{Float64}(undef, (2, 3));julia> typeof(a) === FixedSizeArray{Float64, 2, Memory{Float64}} === FixedSizeArrayDims{Float64, 2, Tuple{Int, Int}, Memory{Float64}}truejulia> b = FixedSizeArrayDims{Int}(undef, (Val(2), Val(3), 2)); # two static dimensionsjulia> typeof(b)FixedSizeArrayDims{Int64, 3, Tuple{Val{2}, Val{3}, Int64}, Memory{Int64}}julia> size(b), size(b, 1), strides(b)((2, 3, 2), 2, (1, 2, 6))julia> using Static: static, StaticIntjulia> c = FixedSizeArrayDims{Int}(undef, (static(2), 3)); # a static dimension from Static.jljulia> typeof(c)FixedSizeArrayDims{Int64, 2, Tuple{StaticInt{2}, Int64}, Memory{Int64}}FixedSizeArrays.FixedSizeVector — Type
FixedSizeVector{T,Mem<:DenseVector{T}}(undef, size::NTuple{1,Int})
FixedSizeVector{T,Mem<:DenseVector{T}}(undef, size1::Int)
FixedSizeVector{T,Mem<:DenseVector{T}}(array::AbstractVector)Construct a fixed-size 1-dimensional FixedSizeArray with element type T, and memory backend Mem.
Convenient aliases provided:
FixedSizeVectorDefault{T}: for 1-dimensional fixed-size arrays, with default memory backend
FixedSizeArrays.FixedSizeMatrix — Type
FixedSizeMatrix{T,Mem<:DenseMatrix{T}}(undef, size::NTuple{2,Int})
FixedSizeMatrix{T,Mem<:DenseMatrix{T}}(undef, size1::Int, size2::Int)
FixedSizeMatrix{T,Mem<:DenseMatrix{T}}(array::AbstractMatrix)Construct a fixed-size 2-dimensional FixedSizeArray with element type T, and memory backend Mem.
Convenient aliases provided:
FixedSizeMatrixDefault{T}: for 2-dimensional fixed-size arrays, with default memory backend
FixedSizeArrays.FixedSizeArrayDefault — Type
FixedSizeArrayDefault{T,N}(undef, size::NTuple{N,Int})
FixedSizeArrayDefault{T,N}(undef, size1::Int, size2::Int, ...)
FixedSizeArrayDefault{T,N}(array::AbstractArray)Construct a FixedSizeArray with element type T, number of dimensions N, and the default memory backend (Vector{T} on Julia v1.10, Memory{T} on Julia v1.11+).
FixedSizeArrays.FixedSizeVectorDefault — Type
FixedSizeVectorDefault{T}(undef, size::NTuple{1,Int})
FixedSizeVectorDefault{T}(undef, size1::Int)
FixedSizeVectorDefault{T}(array::AbstractVector)Construct a FixedSizeVector with element type T, and the default memory backend (Vector{T} on Julia v1.10, Memory{T} on Julia v1.11+).
FixedSizeArrays.FixedSizeMatrixDefault — Type
FixedSizeMatrixDefault{T}(undef, size::NTuple{2,Int})
FixedSizeMatrixDefault{T}(undef, size1::Int, size2::Int)
FixedSizeMatrixDefault{T}(array::AbstractMatrix)Construct a FixedSizeMatrix with element type T, and the default memory backend (Vector{T} on Julia v1.10, Memory{T} on Julia v1.11+).
Base.parent — Function
parent(f::FixedSizeArrayDims)Return the underlying parent object of the fixed-size array f, a DenseVector of length length(f). Use parentindices(f) to get the valid indices of the parent of f.
FixedSizeArrays.wrap — Function
FixedSizeArrays.wrap(FixedSizeArray, parent::DenseVector, size::NTuple{N,Integer})
FixedSizeArrays.wrap(FixedSizeArray, parent::DenseVector, size1::Integer, size2::Integer, ...)
FixedSizeArrays.wrap(FixedSizeArray, parent::DenseVector)
FixedSizeArrays.wrap(FixedSizeArrayDims, parent::DenseVector, size::NTuple{N,Integer})
FixedSizeArrays.wrap(FixedSizeArrayDims, parent::DenseVector, size1::Integer, size2::Integer, ...)
FixedSizeArrays.wrap(FixedSizeArrayDims, parent::DenseVector)Return a FixedSizeArray of the given size which uses parent as its memory backend, without copying. length(parent) must be equal to prod(size), otherwise a DimensionMismatch is thrown. At most one dimension can be given as :, it is then computed from length(parent). Without size, the result is a vector of length length(parent).
With FixedSizeArrayDims as the first argument, the dimensions can also be Vals or StaticInts, for an array with static dimensions.
The first argument can also be a more specific type, e.g. FixedSizeArray{T,N,Mem} or FixedSizeArrayDims{T,N,D,Mem}: the dimensions are converted to the dimensions type of the array (to Ints for a FixedSizeArray), and the element type, the number of dimensions and the memory backend are checked against parent and the dimensions.
The result shares its elements with parent, and parent(FixedSizeArrays.wrap(FixedSizeArray, p, size)) === p. Changing the length of parent (e.g. with resize! when parent is a Vector) while the result is in use is not allowed: wrap parent again after resizing it instead.
This is similar to the (non-public) Base.wrap(Array, mem, dims) in Julia v1.11+, except that parent must have exactly the length of the result.
Examples
julia> using FixedSizeArraysjulia> v = collect(1:6);julia> a = FixedSizeArrays.wrap(FixedSizeArray, v, (2, 3));julia> size(a), parent(a) === v((2, 3), true)julia> a[2, 3] = 60; # writes to `v`julia> v[6]60julia> resize!(v, 8); # invalidates `a`julia> b = FixedSizeArrays.wrap(FixedSizeArray, v, 2, 4); # wrap again after resizingjulia> size(b), b[2, 3]((2, 4), 60)With static dimensions:
julia> using FixedSizeArrays: FixedSizeArrays, FixedSizeArrayDimsjulia> v = collect(1.0:12.0);julia> a = FixedSizeArrays.wrap(FixedSizeArrayDims, v, (Val(2), 3, Val(2)));julia> size(a), parent(a) === v((2, 3, 2), true)julia> size(FixedSizeArrays.wrap(FixedSizeArrayDims, resize!(v, 18), (Val(2), Val(3), :))) # wrap again after resizing(2, 3, 3)FixedSizeArrays.FixedSizeArrayDims — Type
FixedSizeArrayDims{T,N,D,Mem<:DenseVector{T}} <: DenseArray{T,N}Construct a fixed-size FixedSizeArrayDims with element type T, number of dimensions N, dimensions D, and memory backend Mem.
The dimensions type D is a tuple type of Ints (dynamic dimensions) and Vals or StaticInts from Static.jl (static dimensions): FixedSizeArray{T,N,Mem} is FixedSizeArrayDims{T,N,NTuple{N,Int},Mem}, with all dimensions dynamic. Use FixedSizeArrayDims to construct a FixedSizeArray with static dimensions, see FixedSizeArray and FixedSizeArrays.wrap:
FixedSizeArrayDims{T}(undef, dims::Tuple)FixedSizeArrayDims{T,N,D,Mem}(undef, dims::Tuple)FixedSizeArrayDims{T,N,D,Mem}(array::AbstractArray)FixedSizeArrays.wrap(FixedSizeArrayDims, parent::DenseVector, dims::Tuple)Internal API
This section gathers documentation of internal functionalities of FixedSizeArrays.jl which are only of interest to the developers of and contributors to this package.
The following functionalities are not part of the public API of the package and should not be relied upon by external packages, as they can be modified or removed at any point without notice.
FixedSizeArrays.with_stripped_type_parameters — Function
with_stripped_type_parameters(spec, t::Type)::Val{s}The type s is a UnionAll supertype of t:
(s isa UnionAll) && (t <: s)Furthermore, s has type variables in place of the type parameters specified via spec.
NB: Val{s}() is returned instead of s so the method would be consistent from the point of view of Julia's effect inference, enabling constant folding.
NB: this function is supposed to only have the one method. To add functionality, add methods to with_stripped_type_parameters_unchecked.
FixedSizeArrays.with_stripped_type_parameters_unchecked — Function
with_stripped_type_parameters_unchecked(spec, t::Type)::Val{s}An implementation detail of with_stripped_type_parameters. Don't call directly.
FixedSizeArrays.static_dims — Function
static_dims(a::FixedSizeArrayDims)::TupleReturn the dimensions of a, a tuple of StaticInts, Vals and Ints.