4 ms·
For your first request, that's already implemented. It's just not in the readme for some reason. Maybe a PR would be appreciated Here's static shape checking o
by eigenspace 6y ago
For your first request, that's already implemented. It's just not in the readme for some reason. Maybe a PR would be appreciated
Here's static shape checking of arrays:
julia> using StaticArrays, JET
julia> x = SizedVector{3}(rand(3)); y = SizedMatrix{4, 3}(rand(4, 3));
julia> f(x, y) = x' * (y*x)
f (generic function with 1 method)
julia> @report_call f(x, y)
═════ 1 possible error found ═════
┌ @ REPL[9]:1 Main.*(Main.'(x), Main.*(y, x))
│┌ @ /home/mason/julia/usr/share/julia/stdlib/v1.6/LinearAlgebra/src/adjtrans.jl:308 LinearAlgebra.dot(Base.getproperty(u, :parent), v)
││┌ @ /home/mason/.julia/packages/StaticArrays/NTbHj/src/linalg.jl:189 StaticArrays.same_size(a, b)
│││┌ @ /home/mason/.julia/packages/StaticArrays/NTbHj/src/traits.jl:186 StaticArrays._throw_size_mismatch(as...)
││││┌ @ /home/mason/.julia/packages/StaticArrays/NTbHj/src/traits.jl:191 StaticArrays._throw_size_mismatch(::SizedVector{3, Float64, Vector{Float64}}, ::SizedVector{4, Float64, Vector{Float64}})
│││││ may throw: StaticArrays.throw(StaticArrays.DimensionMismatch(Base.string("Sizes ", StaticArrays.map(StaticArrays._size, Argument(2))::Any, " of input arrays do not match")::Any)::Any)
││││└────────────────────────────────────────────────────────────────────
Union{}
julia> @report_call f(x, x*x')
No errors !
Float64