Skip to content

Commit 5cdc0d0

Browse files
Move FieldArray to Core (#1077)
* Move FieldArray to Core * more some tests to group B * Update Project.toml Co-authored-by: Yuto Horikawa <hyrodium@gmail.com> Co-authored-by: Yuto Horikawa <hyrodium@gmail.com>
1 parent f9c10d2 commit 5cdc0d0

File tree

4 files changed

+6
-116
lines changed

4 files changed

+6
-116
lines changed

Project.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
name = "StaticArrays"
22
uuid = "90137ffa-7385-5640-81b9-e52037218182"
3-
version = "1.5.3"
3+
version = "1.5.4"
44

55
[deps]
66
LinearAlgebra = "37e2e46d-f89d-539d-b4ee-838fcccc9c8e"
@@ -10,7 +10,7 @@ Statistics = "10745b16-79ce-11e8-11f9-7d13ad32a3b2"
1010

1111
[compat]
1212
julia = "1.6"
13-
StaticArraysCore = "1"
13+
StaticArraysCore = "~1.1"
1414

1515
[extras]
1616
BenchmarkTools = "6e4b80f9-dd63-53aa-95a3-0cdb28fa8baf"

src/FieldArray.jl

Lines changed: 0 additions & 111 deletions
Original file line numberDiff line numberDiff line change
@@ -1,114 +1,3 @@
1-
"""
2-
abstract FieldArray{N, T, D} <: StaticArray{N, T, D}
3-
4-
Inheriting from this type will make it easy to create your own rank-D tensor types. A `FieldArray`
5-
will automatically define `getindex` and `setindex!` appropriately. An immutable
6-
`FieldArray` will be as performant as an `SArray` of similar length and element type,
7-
while a mutable `FieldArray` will behave similarly to an `MArray`.
8-
9-
Note that you must define the fields of any `FieldArray` subtype in column major order. If you
10-
want to use an alternative ordering you will need to pay special attention in providing your
11-
own definitions of `getindex`, `setindex!` and tuple conversion.
12-
13-
If you define a `FieldArray` which is parametric on the element type you should
14-
consider defining `similar_type` as in the `FieldVector` example.
15-
16-
17-
# Example
18-
19-
struct Stiffness <: FieldArray{Tuple{2,2,2,2}, Float64, 4}
20-
xxxx::Float64
21-
yxxx::Float64
22-
xyxx::Float64
23-
yyxx::Float64
24-
xxyx::Float64
25-
yxyx::Float64
26-
xyyx::Float64
27-
yyyx::Float64
28-
xxxy::Float64
29-
yxxy::Float64
30-
xyxy::Float64
31-
yyxy::Float64
32-
xxyy::Float64
33-
yxyy::Float64
34-
xyyy::Float64
35-
yyyy::Float64
36-
end
37-
"""
38-
abstract type FieldArray{N, T, D} <: StaticArray{N, T, D} end
39-
40-
"""
41-
abstract FieldMatrix{N1, N2, T} <: FieldArray{Tuple{N1, N2}, 2}
42-
43-
Inheriting from this type will make it easy to create your own rank-two tensor types. A `FieldMatrix`
44-
will automatically define `getindex` and `setindex!` appropriately. An immutable
45-
`FieldMatrix` will be as performant as an `SMatrix` of similar length and element type,
46-
while a mutable `FieldMatrix` will behave similarly to an `MMatrix`.
47-
48-
Note that the fields of any subtype of `FieldMatrix` must be defined in column
49-
major order unless you are willing to implement your own `getindex`.
50-
51-
If you define a `FieldMatrix` which is parametric on the element type you
52-
should consider defining `similar_type` as in the `FieldVector` example.
53-
54-
# Example
55-
56-
struct Stress <: FieldMatrix{3, 3, Float64}
57-
xx::Float64
58-
yx::Float64
59-
zx::Float64
60-
xy::Float64
61-
yy::Float64
62-
zy::Float64
63-
xz::Float64
64-
yz::Float64
65-
zz::Float64
66-
end
67-
68-
Note that the fields of any subtype of `FieldMatrix` must be defined in column major order.
69-
This means that formatting of constructors for literal `FieldMatrix` can be confusing. For example
70-
71-
sigma = Stress(1.0, 2.0, 3.0,
72-
4.0, 5.0, 6.0,
73-
7.0, 8.0, 9.0)
74-
75-
3×3 Stress:
76-
1.0 4.0 7.0
77-
2.0 5.0 8.0
78-
3.0 6.0 9.0
79-
80-
will give you the transpose of what the multi-argument formatting suggests. For clarity,
81-
you may consider using the alternative
82-
83-
sigma = Stress(SA[1.0 2.0 3.0;
84-
4.0 5.0 6.0;
85-
7.0 8.0 9.0])
86-
"""
87-
abstract type FieldMatrix{N1, N2, T} <: FieldArray{Tuple{N1, N2}, T, 2} end
88-
89-
"""
90-
abstract FieldVector{N, T} <: FieldArray{Tuple{N}, 1}
91-
92-
Inheriting from this type will make it easy to create your own vector types. A `FieldVector`
93-
will automatically define `getindex` and `setindex!` appropriately. An immutable
94-
`FieldVector` will be as performant as an `SVector` of similar length and element type,
95-
while a mutable `FieldVector` will behave similarly to an `MVector`.
96-
97-
If you define a `FieldVector` which is parametric on the element type you
98-
should consider defining `similar_type` to preserve your array type through
99-
array operations as in the example below.
100-
101-
# Example
102-
103-
struct Vec3D{T} <: FieldVector{3, T}
104-
x::T
105-
y::T
106-
z::T
107-
end
108-
109-
StaticArrays.similar_type(::Type{<:Vec3D}, ::Type{T}, s::Size{(3,)}) where {T} = Vec3D{T}
110-
"""
111-
abstract type FieldVector{N, T} <: FieldArray{Tuple{N}, T, 1} end
1121

1132
@inline (::Type{FA})(x::Tuple) where {FA <: FieldArray} = construct_type(FA, x)(x...)
1143

src/StaticArrays.jl

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@ using LinearAlgebra: checksquare
2727
using StaticArraysCore: StaticArraysCore, StaticArray, StaticScalar, StaticVector,
2828
StaticMatrix, StaticVecOrMat, tuple_length, tuple_prod,
2929
tuple_minimum, size_to_tuple, require_one_based_indexing
30+
using StaticArraysCore: FieldArray, FieldMatrix, FieldVector
3031
import StaticArraysCore: SArray, SVector, SMatrix
3132
import StaticArraysCore: MArray, MVector, MMatrix
3233
import StaticArraysCore: SizedArray, SizedVector, SizedMatrix

test/runtests.jl

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,13 +66,13 @@ if TEST_GROUP ∈ ["", "all", "group-A"]
6666
addtests("inv.jl")
6767
addtests("pinv.jl")
6868
addtests("solve.jl")
69+
end
70+
71+
if TEST_GROUP ["", "all", "group-B"]
6972
addtests("eigen.jl")
7073
addtests("expm.jl")
7174
addtests("sqrtm.jl")
7275
addtests("lyap.jl")
73-
end
74-
75-
if TEST_GROUP ["", "all", "group-B"]
7676
addtests("lu.jl")
7777
addtests("qr.jl")
7878
addtests("chol.jl") # hermitian_type(::Type{Any}) for block algorithm

0 commit comments

Comments
 (0)