88[ ![ Coverage Status] ( https://coveralls.io/repos/github/JuliaArrays/StaticArrays.jl/badge.svg?branch=master )] ( https://coveralls.io/github/JuliaArrays/StaticArrays.jl?branch=master )
99
1010** StaticArrays** provides a framework for implementing statically sized arrays
11- in Julia (≥ 0.5), using the abstract type ` StaticArray{T,N} <: AbstractArray{T,N} ` .
11+ in Julia (≥ 0.5), using the abstract type ` StaticArray{Size, T,N} <: AbstractArray{T,N} ` .
1212Subtypes of ` StaticArray ` will provide fast implementations of common array and
1313linear algebra operations. Note that here "statically sized" means that the
14- size can be determined from the * type* (so concrete implementations of
15- ` StaticArray ` must define a method ` size(::Type{T}) ` ), and "static" does ** not**
16- necessarily imply ` immutable ` .
14+ size can be determined from the * type* , and "static" does ** not** necessarily
15+ imply ` immutable ` .
1716
1817The package also provides some concrete static array types: ` SVector ` , ` SMatrix `
1918and ` SArray ` , which may be used as-is (or else embedded in your own type).
@@ -172,9 +171,6 @@ reshape(svector, Size(2,2)) # Convert SVector{4} to SMatrix{2,2}
172171Size (3 ,3 )(rand (3 ,3 )) # Construct a random 3×3 SizedArray (see below)
173172```
174173
175- Users that introduce a new subtype of ` StaticArray ` should define a (` @pure ` )
176- method for ` Size(::Type{NewArrayType}) ` .
177-
178174### Indexing
179175
180176Statically sized indexing can be realized by indexing each dimension by a
@@ -212,13 +208,8 @@ specifying the size as plain integers).
212208
213209### ` SVector `
214210
215- The simplest static array is the ` SVector ` , defined as
216-
217- ``` julia
218- immutable SVector{N,T} <: StaticVector{T}
219- data:: NTuple{N,T}
220- end
221- ```
211+ The simplest static array is the type ` SVector{N,T} ` , which provides an
212+ immutable vector of fixed length ` N ` and type ` T ` .
222213
223214` SVector ` defines a series of convenience constructors, so you can just type
224215e.g. ` SVector(1,2,3) ` . Alternatively there is an intelligent ` @SVector ` macro
@@ -234,36 +225,27 @@ limitation.)
234225
235226### ` SMatrix `
236227
237- Static matrices are also provided by ` SMatrix ` . It's definition is a little
238- more complicated:
239-
240- ``` julia
241- immutable SMatrix{S1, S2, T, L} <: StaticMatrix{T}
242- data:: NTuple{L, T}
243- end
244- ```
228+ Statically sized ` N×M ` matrices are provided by ` SMatrix{N,M,T,L} ` .
245229
246- Here ` L ` is the ` length ` of the matrix, such that ` S1 × S2 = L` . However,
247- convenience constructors are provided, so that ` L ` , ` T ` and even ` S2 ` are
230+ Here ` L ` is the ` length ` of the matrix, such that ` N × M = L` . However,
231+ convenience constructors are provided, so that ` L ` , ` T ` and even ` M ` are
248232unnecessary. At minimum, you can type ` SMatrix{2}(1,2,3,4) ` to create a 2×2
249- matrix (the total number of elements must divide evenly into ` S1 ` ). A
233+ matrix (the total number of elements must divide evenly into ` N ` ). A
250234convenience macro ` @SMatrix [1 2; 3 4] ` is provided (which also accepts
251235comprehensions and the ` zeros() ` , ` ones() ` , ` fill() ` , ` rand() ` , ` randn() ` and ` eye() `
252236functions).
253237
254238### ` SArray `
255239
256240A container with arbitrarily many dimensions is defined as
257- ` immutable SArray{Size,T,N,L} <: StaticArray{T,N} ` , where
258- ` Size = ( S1, S2, ...) ` is a tuple of ` Int ` s. You can easily construct one with
241+ ` immutable SArray{Size,T,N,L} <: StaticArray{Size, T,N} ` , where
242+ ` Size = Tuple{ S1, S2, ...} ` is a tuple of ` Int ` s. You can easily construct one with
259243the ` @SArray ` macro, supporting all the features of ` @SVector ` and ` @SMatrix `
260244(but with arbitrary dimension).
261245
262- Notably, the main reason ` SVector ` and ` SMatrix ` are defined is to make it
263- easier to define the types without the extra tuple characters (compare
264- ` SVector{3} ` to ` SArray{(3,)} ` ). This extra convenience was made possible
265- because it is so easy to define new ` StaticArray ` subtypes, and they naturally
266- work together.
246+ The main reason ` SVector ` and ` SMatrix ` are defined is to make it easier to
247+ define the types without the extra tuple characters (compare ` SVector{3} ` to
248+ ` SArray{Tuple{3}} ` ).
267249
268250### ` Scalar `
269251
@@ -307,7 +289,7 @@ Convenience macros `@MVector`, `@MMatrix` and `@MArray` are provided.
307289
308290Another convenient mutable type is the ` SizedArray ` , which is just a wrapper-type
309291about a standard Julia ` Array ` which declares its knwon size. For example, if
310- we knew that ` a ` was a 2×2 ` Matrix ` , then we can type ` sa = SizedArray{( 2,2) }(a) `
292+ we knew that ` a ` was a 2×2 ` Matrix ` , then we can type ` sa = SizedArray{Tuple{ 2,2} }(a) `
311293to construct a new object which knows the type (the size will be verified
312294automatically). A more convenient syntax for obtaining a ` SizedArray ` is by calling
313295a ` Size ` object, e.g. ` sa = Size(2,2)(a) ` .
0 commit comments