5
5
[ ![ Build Status] ( https://travis-ci.org/JuliaArrays/StaticArrays.jl.svg?branch=master )] ( https://travis-ci.org/JuliaArrays/StaticArrays.jl )
6
6
[ ![ Build status] ( https://ci.appveyor.com/api/projects/status/xabgh1yhsjxlp30d?svg=true )] ( https://ci.appveyor.com/project/JuliaArrays/staticarrays-jl )
7
7
[ ![ Coverage Status] ( https://coveralls.io/repos/github/JuliaArrays/StaticArrays.jl/badge.svg?branch=master )] ( https://coveralls.io/github/JuliaArrays/StaticArrays.jl?branch=master )
8
- [ ![ codecov.io] ( http ://codecov.io/github/JuliaArrays/StaticArrays.jl/coverage.svg? branch= master)] ( http://codecov.io/github/JuliaArrays/StaticArrays.jl? branch= master )
8
+ [ ![ codecov.io] ( https ://codecov.io/github/JuliaArrays/StaticArrays.jl/branch/ master/graph/badge.svg )] ( http://codecov.io/github/JuliaArrays/StaticArrays.jl/ branch/ master )
9
9
[ ![ ] ( https://img.shields.io/badge/docs-latest-blue.svg )] ( https://JuliaArrays.github.io/StaticArrays.jl/latest )
10
10
[ ![ ] ( https://img.shields.io/badge/docs-stable-blue.svg )] ( https://JuliaArrays.github.io/StaticArrays.jl/stable )
11
11
12
12
** StaticArrays** provides a framework for implementing statically sized arrays
13
- in Julia (≥ 0.5) , using the abstract type ` StaticArray{Size,T,N} <: AbstractArray{T,N} ` .
13
+ in Julia, using the abstract type ` StaticArray{Size,T,N} <: AbstractArray{T,N} ` .
14
14
Subtypes of ` StaticArray ` will provide fast implementations of common array and
15
15
linear algebra operations. Note that here "statically sized" means that the
16
16
size can be determined from the * type* , and "static" does ** not** necessarily
@@ -27,40 +27,34 @@ Full documentation can be found [here](https://JuliaArrays.github.io/StaticArray
27
27
## Speed
28
28
29
29
The speed of * small* ` SVector ` s, ` SMatrix ` s and ` SArray ` s is often > 10 × faster
30
- than ` Base.Array ` . See this simplified benchmark (or see the full results [ here ] ( https://github.com/andyferris/StaticArrays.jl/blob/master/perf/bench10.txt ) ) :
30
+ than ` Base.Array ` . See this simplified benchmark:
31
31
32
32
```
33
33
============================================
34
34
Benchmarks for 3×3 Float64 matrices
35
35
============================================
36
-
37
- Matrix multiplication -> 8.2x speedup
38
- Matrix multiplication (mutating) -> 3.1x speedup
39
- Matrix addition -> 45x speedup
40
- Matrix addition (mutating) -> 5.1x speedup
41
- Matrix determinant -> 170x speedup
42
- Matrix inverse -> 125x speedup
43
- Matrix symmetric eigendecomposition -> 82x speedup
44
- Matrix Cholesky decomposition -> 23.6x speedup
36
+ Matrix multiplication -> 5.1x speedup
37
+ Matrix multiplication (mutating) -> 1.6x speedup
38
+ Matrix addition -> 14.0x speedup
39
+ Matrix addition (mutating) -> 2.1x speedup
40
+ Matrix determinant -> 119.3x speedup
41
+ Matrix inverse -> 65.6x speedup
42
+ Matrix symmetric eigendecomposition -> 24.8x speedup
43
+ Matrix Cholesky decomposition -> 12.1x speedup
45
44
```
46
45
47
- These results improve significantly when using ` julia -O3 ` with immutable static
48
- arrays, as the extra optimization results in surprisingly good SIMD code.
49
-
50
46
Note that in the current implementation, working with large ` StaticArray ` s puts a
51
47
lot of stress on the compiler, and becomes slower than ` Base.Array ` as the size
52
48
increases. A very rough rule of thumb is that you should consider using a
53
- normal ` Array ` for arrays larger than 100 elements. For example, the performance
54
- crossover point for a matrix multiply microbenchmark seems to be about 11x11 in
55
- julia 0.5 with default optimizations.
49
+ normal ` Array ` for arrays larger than 100 elements.
56
50
57
51
58
52
## Quick start
59
53
54
+ Add * StaticArrays* from the [ Pkg REPL] ( https://docs.julialang.org/en/latest/stdlib/Pkg/#Getting-Started-1 ) , i.e., ` pkg> add StaticArrays ` . Then:
60
55
``` julia
61
- Pkg. add (" StaticArrays" ) # or Pkg.clone("https://github.com/JuliaArrays/StaticArrays.jl")
62
- using StaticArrays
63
56
using LinearAlgebra
57
+ using StaticArrays
64
58
65
59
# Create an SVector using various forms, using constructors, functions or macros
66
60
v1 = SVector (1 , 2 , 3 )
@@ -104,7 +98,8 @@ rand(MMatrix{20,20}) * rand(MMatrix{20,20}) # large matrices can use BLAS
104
98
eigen (m3) # eigen(), etc uses specialized algorithms up to 3×3, or else LAPACK
105
99
106
100
# Static arrays stay statically sized, even when used by Base functions, etc:
107
- typeof (eigen (m3)) == Eigen{Float64,Float64,SArray{Tuple{3 ,3 },Float64,2 ,9 },SArray{Tuple{3 },Float64,1 ,3 }}
101
+ typeof (eigen (m3). vectors) == SMatrix{3 ,3 ,Float64,9 }
102
+ typeof (eigen (m3). values) == SVector{3 ,Float64}
108
103
109
104
# similar() returns a mutable container, while similar_type() returns a constructor:
110
105
typeof (similar (m3)) == MArray{Tuple{3 ,3 },Int64,2 ,9 } # (final parameter is length = 9)
@@ -138,27 +133,7 @@ performance optimizations may be made when the size of the array is known to the
138
133
compiler. One example of this is by loop unrolling, which has a substantial
139
134
effect on small arrays and tends to automatically trigger LLVM's SIMD
140
135
optimizations. Another way performance is boosted is by providing specialized
141
- methods for ` det ` , ` inv ` , ` eig ` and ` chol ` where the algorithm depends on the
136
+ methods for ` det ` , ` inv ` , ` eigen ` and ` cholesky ` where the algorithm depends on the
142
137
precise dimensions of the input. In combination with intelligent fallbacks to
143
138
the methods in Base, we seek to provide a comprehensive support for statically
144
139
sized arrays, large or small, that hopefully "just works".
145
-
146
- ## Relationship to * FixedSizeArrays* and * ImmutableArrays*
147
-
148
- Several existing packages for statically sized arrays have been developed for
149
- Julia, noteably * FixedSizeArrays* and * ImmutableArrays* which provided signficant
150
- inspiration for this package. Upon consultation, it has been decided to move
151
- forward with * StaticArrays* which has found a new home in the * JuliaArrays*
152
- github organization. It is recommended that new users use this package, and
153
- that existing dependent packages consider switching to * StaticArrays* sometime
154
- during the life-cycle of Julia v0.5.
155
-
156
- You can try ` using StaticArrays.FixedSizeArrays ` to add some compatibility
157
- wrappers for the most commonly used features of the * FixedSizeArrays* package,
158
- such as ` Vec ` , ` Mat ` , ` Point ` and ` @fsa ` . These wrappers do not provide a
159
- perfect interface, but may help in trying out * StaticArrays* with pre-existing
160
- code.
161
-
162
- Furthermore, ` using StaticArrays.ImmutableArrays ` will let you use the typenames
163
- from the * ImmutableArrays* package, which does not include the array size as a
164
- type parameter (e.g. ` Vector3{T} ` and ` Matrix3x3{T} ` ).
0 commit comments