In the MixedModels
package one of the structs contains a short, wide matrix for which the primary usage is column-wise. (The struct is VectorFactorReTerm
defined in src/modelterms.jl
for those who want to play along at home.) To speed up such accesses I create a Vector
of Svector
s from the columns using
reinterpret(SVector{k,T}, vec(z))
where z
is a Matrix{T}
of size k
by n
. This is slightly modified from the suggested form in the documentation for StaticArrays
under “Arrays of static arrays”.
Julia v0.6 was okay with this and I could define the field in the struct as Vector{SVector{k,T}}
.
In Julia v0.7 I get an error about the type of the field
UBlk: Error During Test at /home/bates/.julia/dev/MixedModels/test/UniformBlockDiagonal.jl:7
Got exception MethodError(VectorFactorReTerm, (UInt32[0x00000001, 0x00000001, 0x00000001, 0x00000001, 0x00000002, 0x00000002, 0x00000002, 0x00000002, 0x00000003, 0x00000003, 0x00000003, 0x00000003], ["1", "2", "3"], [1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0; -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0], [1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0 1.0; -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0 -1.0 1.0], StaticArrays.SArray{Tuple{2},Float64,1,2}[[1.0, -1.0], [1.0, 1.0], [1.0, -1.0], [1.0, 1.0], [1.0, -1.0], [1.0, 1.0], [1.0, -1.0], [1.0, 1.0], [1.0, -1.0], [1.0, 1.0], [1.0, -1.0], [1.0, 1.0]], :G, ["(Intercept)", "U"], [2], [1.0 0.0; 0.0 1.0], [1, 2, 4]), 0x0000000000006c74) outside of a @test
MethodError: no method matching VectorFactorReTerm(::Array{UInt32,1}, ::Array{String,1}, ::Array{Float64,2}, ::Array{Float64,2}, ::Base.ReinterpretArray{StaticArrays.SArray{Tuple{2},Float64,1,2},1,Float64,Array{Float64,1}}, ::Symbol, ::Array{String,1}, ::Array{Int64,1}, ::LowerTriangular{Float64,Array{Float64,2}}, ::Array{Int64,1})
Closest candidates are:
VectorFactorReTerm(::Array{R,1}, ::Array{String,1}, ::Array{T,2}, ::Array{T,2}, !Matched::Array{StaticArrays.SArray{Tuple{S},T,1,S},1}, ::Symbol, ::Array{String,1}, ::Array{Int64,1}, ::LowerTriangular{T,Array{T,2}}, ::Array{Int64,1}) where {T, R, S} at /home/bates/.julia/dev/MixedModels/src/modelterms.jl:159
VectorFactorReTerm(!Matched::CategoricalArray{T,1,V,C,U,U1} where U1 where U where C where V where T, !Matched::Array{T,2}, ::Any, ::Any, ::Any) where T at /home/bates/.julia/dev/MixedModels/src/modelterms.jl:171
apparently because the reinterpret
is lazy.
So my question is how to instantiate the actual type after the lazy reinterpret. I appreciate that much of the linear algebra manipulations have become lazy and I certainly appreciate that change but I am not yet sure how to say, “I really mean it now - give me one of these instead of a delayed expression formulation.”