In the following example
struct Foo
colind::Int
A::Matrix{Float64}
v::Vector{Float64}
end
function copycol!(foo::Foo)
for i in eachindex(foo.v)
foo.v[i] = foo.A[i, foo.colind]
end
foo
end
will the compiler recognize that all of the field extractions inside the loop are loop invariants?
At present I would write copycol!
as
function copycol!(foo::Foo)
colind = foo.colind
A = foo.A
v = foo.v
for i in eachindex(v)
v[i] = A[i, colind]
end
foo
end
Am I telling the compiler something it will easily recognize on its own?