Registered Member
|
I have an algorithm of the form,
Q1*A = B Q2*C = D where Q1 and Q2 are orthogonal matrices which upper-triangularize A and C respectively into B and D. This is done repeatedly (this is a Kalman filter algorithm of the array type). Now, A, B, C, D are block matrices; certain blocks of B go into C, and certain blocks of D go into A. Right now I copy those blocks at each iteration, but I wonder if somehow I could overlay the relevant blocks of B and C (and D and A) to share the same memory, thus avoiding the copies. I have been looking at Ref, but I dont quite see if that could be put to task to solve my problem. I would welcome any suggestions or pointers to examples I may look at. |
Moderator
|
Sorry for late reply. I don't quite see what you exactly means by "certain blocks of B go into C", but the most flexible mechanism to create matrix views over memory buffers is the Map class. With Map, you can see as an Eigen matrix any memory layout of the form A(i,j) = data[i*innerStride+j*outerStride].
You might also search for Kalman filter within this forum, I remember that some users posted their code. |
Registered Member
|
I meant that if B and C are made of blocks,
( B11 B12) (C11 C12) ( B21 B22) (C21 C22) then, once I compute B, I need to copy block, say, B22 into block C21. I was after a way of making C21 and B22 share the same memory. I had thought of using strides, but I do not seem able to get the thing right. If you could point me to some example where different blocks of a matrix are mapped to different memory blocks I think I might be able to modify it for my purposes. Thank you very much for your reply. |
Moderator
|
I see, then I'm afraid that's not possible unless you deal with the different blocks manually, this is you never play with B but only with its sub blocks individually.
|
Registered Member
|
OK. Problem is, dealing with the blocks individually means rewriting much code. For instance,
when finding eigenvalues or a matriz factorization for B, I would no longer be able to use a routine that uses the whole of B. I guess I will have to live with copying blocks back and forth. Thank you very much anyway. |
Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]