Need a rarely used binary operator for matrices

You don’t normally get any allocations as long as the sizes are statically known. It is easy for the compiler to see that [x; 1] will have type SVector{4, Float64}, though you could also use StaticArrays.push with no difference.

If you want to get rid of the last element of the output vector (which is common), you can use StaticArrays.pop. This can be quite useful, since

julia> typeof(x[1:end-1])
Vector{Float64} (alias for Array{Float64, 1})

julia> typeof(pop(x))
SVector{2, Float64} (alias for SArray{Tuple{2}, Float64, 1, 2})
1 Like