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

matrix assignment

Tags: None
(comma "," separated)
lorniper
Registered Member
Posts
3
Karma
0

matrix assignment

Tue Apr 29, 2014 1:58 pm
I have to perform matrix production for really a lot of times in some loops. (parallelized by openmp)

I found that this assignment sometimes cause problems
A = G * A , where e.g. G(10,10), A(10,100)

While A_temp= G * A; A=A_temp is always safe, is there any explanation?


thanks!

Last edited by lorniper on Wed Apr 30, 2014 2:02 pm, edited 1 time in total.
User avatar
benoitsteiner
Registered Member
Posts
13
Karma
0

Re: matrix assignment

Tue Apr 29, 2014 8:25 pm
The dimension of your G*A product is 10x100, and you're trying to store the result in A which is 100*100. The dimension mismatch is likely what gets your in trouble. Try something like this instead: A.block(10, 100) = G * A;


lorniper
Registered Member
Posts
3
Karma
0

Re: matrix assignment

Wed Apr 30, 2014 2:01 pm
sorry, I made a typo, it should be A = G * A , where e.g. G(10,10), A(10,100),

then is it always reliable for this overwritten operation? casuse i really got some wierd results if no temp has been used.

thanks
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: matrix assignment

Wed Apr 30, 2014 3:22 pm
That's strange because by default matrix products evaluate in a temporary. My guess is that there is a memory issue somewhere else. Valgrind my help you.
User avatar
ggael
Moderator
Posts
3447
Karma
19
OS

Re: matrix assignment

Wed Apr 30, 2014 3:23 pm
I see you're using openmp, don't miss this page: http://eigen.tuxfamily.org/dox/TopicMultiThreading.html


Bookmarks



Who is online

Registered users: Baidu [Spider], Bing [Bot], Google [Bot], rblackwell