Is there a way to pre-allocate an array to hold the returned eigenvalues and vectors from eigen
or eigen!
? Currently both functions return a factorization which does not seem to allow a pre-allocation. The following code shows what I would like to do but does not work:
julia> A=rand(100,100);
julia> evals=zeros(CF64,100);
julia> evecs=zeros(CF64,100,100);
julia> julia> esys=Eigen(evals,evecs);
julia> esys.values[1]
0.0 + 0.0im
julia> evals[1]=1;
julia> esys.values[1]
1.0 + 0.0im
julia> esys = eigen(A)
julia> esys.values[1]
-3.0686209886339606 - 1.1725958631992774im
julia> evals[1]
1.0 + 0.0im
Here CF64=ComplexF64
. I would hope that eigen
would write to evals
and evecs
but apparently it does not. I can also do something like this:
pre-allocated-eigen!(A,evals,evecs);
I haven’t found such a function though. Any suggestions? Or is there a reason why this is not making sense?