@@ -56,7 +56,7 @@ julia 0.5 with default optimizations.
56
56
## Quick start
57
57
58
58
``` julia
59
- Pkg. add (" StaticArrays" ) # or Pkg.clone("https://github.com/andyferris /StaticArrays.jl")
59
+ Pkg. add (" StaticArrays" ) # or Pkg.clone("https://github.com/JuliaArrays /StaticArrays.jl")
60
60
using StaticArrays
61
61
62
62
# Create an SVector using various forms, using constructors, functions or macros
@@ -90,9 +90,9 @@ v8 = sin.(v3)
90
90
v3 == m3 * v3 # recall that m3 = eye(SMatrix{3,3})
91
91
# map, reduce, broadcast, map!, broadcast!, etc...
92
92
93
- # Indexing also supports tuples
93
+ # Indexing can also be done using static arrays of integers
94
94
v1[1 ] === 1
95
- v1[(3 ,2 ,1 )] === @SVector [3 , 2 , 1 ]
95
+ v1[SVector (3 ,2 ,1 )] === @SVector [3 , 2 , 1 ]
96
96
v1[:] === v1
97
97
typeof (v1[[1 ,2 ,3 ]]) <: Vector # Can't determine size from the type of [1,2,3]
98
98
@@ -101,7 +101,7 @@ rand(MMatrix{20,20}) * rand(MMatrix{20,20}) # large matrices can use BLAS
101
101
eig (m3) # eig(), etc uses specialized algorithms up to 3×3, or else LAPACK
102
102
103
103
# Static arrays stay statically sized, even when used by Base functions, etc:
104
- typeof (eig (m3)) == Tuple{MVector {3 ,Float64}, MMatrix {3 ,3 ,Float64,9 }}
104
+ typeof (eig (m3)) == Tuple{SVector {3 ,Float64}, SMatrix {3 ,3 ,Float64,9 }}
105
105
106
106
# similar() returns a mutable container, while similar_type() returns a constructor:
107
107
typeof (similar (m3)) == MMatrix{3 ,3 ,Float64,9 } # (final parameter is length = 9)
@@ -110,15 +110,15 @@ similar_type(m3) == SMatrix{3,3,Float64,9}
110
110
# The Size trait is a compile-time constant representing the size
111
111
Size (m3) === Size (3 ,3 )
112
112
113
- # reshape() uses Size() or types to specify size:
114
- reshape ([1 ,2 ,3 ,4 ], Size (2 ,2 )) === @SMatrix [ 1 3 ;
115
- 2 4 ]
116
- reshape ([1 ,2 ,3 ,4 ], SMatrix{2 ,2 }) === @SMatrix [ 1 3 ;
117
- 2 4 ]
118
-
119
113
# A standard Array can be wrapped into a SizedArray
120
114
m4 = Size (3 ,3 )(rand (3 ,3 ))
121
115
inv (m4) # Take advantage of specialized fast methods
116
+
117
+ # reshape() uses Size() or types to specify size:
118
+ reshape ([1 ,2 ,3 ,4 ], Size (2 ,2 )) == @SMatrix [ 1 3 ;
119
+ 2 4 ]
120
+ typeof (reshape ([1 ,2 ,3 ,4 ], Size (2 ,2 ))) === SizedArray{(2 , 2 ),Int64,2 ,1 }
121
+
122
122
```
123
123
124
124
## Approach
@@ -348,9 +348,9 @@ you may want to define a default constructor (no inputs) that can be called by
348
348
349
349
### Implementing your own types
350
350
351
- You can easily create your own ` StaticArray ` type, by defining both ` Size ` (on the
352
- * type* , e.g. ` StaticArrays.Size(::Type{Point3D}) = Size(3) ` ), and linear
353
- ` getindex ` (and optionally ` setindex! ` for mutable types - see
351
+ You can easily create your own ` StaticArray ` type, by defining both ` Size ` (on the
352
+ * type* , e.g. ` StaticArrays.Size(::Type{Point3D}) = Size(3) ` ), and linear
353
+ ` getindex ` (and optionally ` setindex! ` for mutable types - see
354
354
` setindex(::SVector, val, i) ` in * MVector.jl* for an example of how to
355
355
achieve this through pointer manipulation). Your type should define a constructor
356
356
that takes a tuple of the data (and mutable containers may want to define a
0 commit comments