|
1 | | -""" |
2 | | - MArray{S, T, N, L}(undef) |
3 | | - MArray{S, T, N, L}(x::NTuple{L}) |
4 | | - MArray{S, T, N, L}(x1, x2, x3, ...) |
5 | | -
|
6 | | -
|
7 | | -Construct a statically-sized, mutable array `MArray`. The data may optionally be |
8 | | -provided upon construction and can be mutated later. The `S` parameter is a Tuple-type |
9 | | -specifying the dimensions, or size, of the array - such as `Tuple{3,4,5}` for a 3×4×5-sized |
10 | | -array. The `N` parameter is the dimension of the array; the `L` parameter is the `length` |
11 | | -of the array and is always equal to `prod(S)`. Constructors may drop the `L`, `N` and `T` |
12 | | -parameters if they are inferrable from the input (e.g. `L` is always inferrable from `S`). |
13 | | -
|
14 | | - MArray{S}(a::Array) |
15 | | -
|
16 | | -Construct a statically-sized, mutable array of dimensions `S` (expressed as a `Tuple{...}`) |
17 | | -using the data from `a`. The `S` parameter is mandatory since the size of `a` is unknown to |
18 | | -the compiler (the element type may optionally also be specified). |
19 | | -""" |
20 | | -mutable struct MArray{S <: Tuple, T, N, L} <: StaticArray{S, T, N} |
21 | | - data::NTuple{L,T} |
22 | | - |
23 | | - function MArray{S,T,N,L}(x::NTuple{L,T}) where {S<:Tuple,T,N,L} |
24 | | - check_array_parameters(S, T, Val{N}, Val{L}) |
25 | | - new{S,T,N,L}(x) |
26 | | - end |
27 | | - |
28 | | - function MArray{S,T,N,L}(x::NTuple{L,Any}) where {S<:Tuple,T,N,L} |
29 | | - check_array_parameters(S, T, Val{N}, Val{L}) |
30 | | - new{S,T,N,L}(convert_ntuple(T, x)) |
31 | | - end |
32 | | - |
33 | | - function MArray{S,T,N,L}(::UndefInitializer) where {S<:Tuple,T,N,L} |
34 | | - check_array_parameters(S, T, Val{N}, Val{L}) |
35 | | - new{S,T,N,L}() |
36 | | - end |
37 | | -end |
38 | | - |
39 | | -@inline MArray{S,T,N}(x::Tuple) where {S<:Tuple,T,N} = MArray{S,T,N,tuple_prod(S)}(x) |
40 | 1 |
|
41 | 2 | @generated function (::Type{MArray{S,T,N}})(::UndefInitializer) where {S,T,N} |
42 | 3 | return quote |
|
0 commit comments