Basic question: Is there an
AbstractMatrix which can represent a low-rank factorized matrix?
Example: I have the rank-one matrix:
n1=900; n2=100; u=[zeros(n1);randn(n2)]; A=u*u';
I want to use
A in functions which take
AbstractMatrix as input, and use many matrix vector products (but also sum matrices together). Is there a way to represent
u*u', without multiplying it out?
Current solution: I use that
u has a sparsity pattern and represent
A as a sparse matrix:
The sparse approach is better but not optimal
julia> x=randn(n1+n2); julia> @btime A*x; 345.225 μs (1 allocation: 7.94 KiB) julia> @btime B*x; 9.531 μs (1 allocation: 7.94 KiB) julia> @btime u*(u'*x); 1.044 μs (3 allocations: 7.97 KiB)
and it uses that the vector is sparse (which is not always the case in the application).