Do you actually care about the order of columns? Or can you just use a cyclic representation?
V[:, mod1(col, N)] = v --Tim On Sunday, May 11, 2014 04:48:08 PM Carlos Baptista wrote: > I have an iterative algorithm in which two matrices with a fixed number of > rows grow in number of columns. The algorithm requires only the last > *N*columns (where N is a predefined fixed integer). If the number of > columns grow to *N + d*, then the first *d* columns are no longer required > and can be deleted/overwritten. So what would be an efficient way to let a > matrix grow up to *N* columns and to continue by popping the first column > before appending a new one? Please keep in mind that I need to perform > matvec and qr-decompositions on these matrices. > > A pseudo code of what I would like to do in an efficient manner is this: > > v = myFuncV() > w = myFuncW() > > if size(V, 2) == N > V = [V[:, 2:N] v] > W = [W[:, 2:N] w] > else > V = [V v] > W = [W w] > end
