Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/src/pages/api.md
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ functions).
A container with arbitrarily many dimensions is defined as
`struct SArray{Size,T,N,L} <: StaticArray{Size,T,N}`, where
`Size = Tuple{S1, S2, ...}` is a tuple of `Int`s. You can easily construct one with
the `@SArray` macro, supporting all the features of `@SVector` and `@SMatrix`
the `@SArray` macro (or the short-form `@sa` macro), supporting all the features of `@SVector` and `@SMatrix`
(but with arbitrary dimension).

The main reason `SVector` and `SMatrix` are defined is to make it easier to
Expand Down
4 changes: 4 additions & 0 deletions docs/src/pages/quickstart.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,10 @@ m5 = SMatrix{2,2}([1 3 ; 2 4]) # Array conversions must specify size
# Higher-dimensional support
a = @SArray randn(2, 2, 2, 2, 2, 2)

# Short-form macro for static vectors or matrices
m6 = @sa [1 2; 3 4]
m7 = @sa[1 2; 3 4] * @sa[5, 6] # without space or parenthesis, requires Julia v0.7 or above

# Supports all the common operations of AbstractArray
v7 = v1 + v2
v8 = sin.(v3)
Expand Down
2 changes: 2 additions & 0 deletions src/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -253,6 +253,8 @@ macro SArray(ex)
end
end

macro sa(ex); esc(:(@SArray($ex))); end

function promote_rule(::Type{<:SArray{S,T,N,L}}, ::Type{<:SArray{S,U,N,L}}) where {S,T,U,N,L}
SArray{S,promote_type(T,U),N,L}
end
2 changes: 1 addition & 1 deletion src/StaticArrays.jl
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ export SDiagonal

export Size, Length

export @SVector, @SMatrix, @SArray
export @SVector, @SMatrix, @SArray, @sa
export @MVector, @MMatrix, @MArray

export similar_type
Expand Down
3 changes: 3 additions & 0 deletions test/SArray.jl
Original file line number Diff line number Diff line change
Expand Up @@ -89,6 +89,9 @@

# Non-square comprehensions built from SVectors - see #76
@test @SArray([1 for x = SVector(1,2), y = SVector(1,2,3)]) == ones(2,3)

# @SArray short-form macro
@test @macroexpand(@sa([a b; c d])) == @macroexpand(@SArray([a b; c d]))
end

@testset "Methods" begin
Expand Down