I'm assuming that v is an array of vectors. Does this do any better?

N=zeros(length(v[1]),max(length(v[1]),length(v))) # Because there can't be 
more than this many columns
i=0
for w=v
    if any(w.!=0)&&w!=N[:,1:i]*(N[:,1:i]\w)
      i+=1
      N[:,i]=j
    end
end
N=N[:,1:i]

Note: may have minor issue for rounding errors, so some rounding during 
testing may be necessary to avoid problems. Also, this is written from 0.3, 
I cannot guarantee that everything will work correctly in 0.4.

On Tuesday, 6 October 2015 01:06:15 UTC+10, Matt wrote:
>
> Given a set of vectors v1, ...., vn, I'd like to construct a matrix where 
> columns correspond to a linearly independent subset of these vectors.
> Currenly, I form the matrix hcat(v1, ..., vn), use qrfact!() on it, check 
> the diagonal of the :R matrix and construct a new matrix as hcat(vj,...)
> I'm looking for a way that would use less memory. Is there a more memory 
> efficient way ? (for instance a way to avoid the construction of an 
> intermediary matrix when finding the subset of vectors, or a way to delete 
> columns in place in a matrix)
>

Reply via email to