Skip to content

Commit 91ed94a

Browse files
tkoolenandyferris
authored andcommitted
Update readme examples. (#133)
1 parent bd3236a commit 91ed94a

File tree

1 file changed

+13
-13
lines changed

1 file changed

+13
-13
lines changed

README.md

Lines changed: 13 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ julia 0.5 with default optimizations.
5656
## Quick start
5757

5858
```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")
6060
using StaticArrays
6161

6262
# Create an SVector using various forms, using constructors, functions or macros
@@ -90,9 +90,9 @@ v8 = sin.(v3)
9090
v3 == m3 * v3 # recall that m3 = eye(SMatrix{3,3})
9191
# map, reduce, broadcast, map!, broadcast!, etc...
9292

93-
# Indexing also supports tuples
93+
# Indexing can also be done using static arrays of integers
9494
v1[1] === 1
95-
v1[(3,2,1)] === @SVector [3, 2, 1]
95+
v1[SVector(3,2,1)] === @SVector [3, 2, 1]
9696
v1[:] === v1
9797
typeof(v1[[1,2,3]]) <: Vector # Can't determine size from the type of [1,2,3]
9898

@@ -101,7 +101,7 @@ rand(MMatrix{20,20}) * rand(MMatrix{20,20}) # large matrices can use BLAS
101101
eig(m3) # eig(), etc uses specialized algorithms up to 3×3, or else LAPACK
102102

103103
# 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}}
105105

106106
# similar() returns a mutable container, while similar_type() returns a constructor:
107107
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}
110110
# The Size trait is a compile-time constant representing the size
111111
Size(m3) === Size(3,3)
112112

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-
119113
# A standard Array can be wrapped into a SizedArray
120114
m4 = Size(3,3)(rand(3,3))
121115
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+
122122
```
123123

124124
## Approach
@@ -348,9 +348,9 @@ you may want to define a default constructor (no inputs) that can be called by
348348

349349
### Implementing your own types
350350

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
354354
`setindex(::SVector, val, i)` in *MVector.jl* for an example of how to
355355
achieve this through pointer manipulation). Your type should define a constructor
356356
that takes a tuple of the data (and mutable containers may want to define a

0 commit comments

Comments
 (0)