This forum has been archived. All content is frozen. Please use KDE Discuss instead.

Overlay blocks of matrices

Tags: None
(comma "," separated)
ftusell
Registered Member
Posts
4
Karma
0

Overlay blocks of matrices

Wed Apr 29, 2015 7:47 am
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Overlay blocks of matrices

Mon May 18, 2015 8:57 pm
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.
ftusell
Registered Member
Posts
4
Karma
0

Re: Overlay blocks of matrices

Fri May 22, 2015 7:30 am
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.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: Overlay blocks of matrices

Tue May 26, 2015 9:12 am
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.
ftusell
Registered Member
Posts
4
Karma
0

Re: Overlay blocks of matrices

Tue May 26, 2015 4:00 pm
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.


Bookmarks



Who is online

Registered users: Bing [Bot], Google [Bot], Yahoo [Bot]