Re: [eigen] MatrixX multiply

[ Thread Index | Date Index | More lists.tuxfamily.org/eigen Archives ]


On Thu, 15 Feb 2007, Steven große Deters wrote:

Thank you. Perhaps you could give me some advise so that I could try to do
it on my own in the meantime ?

How could an entry-by-entry product of two (large) matrix's by accomplished
?
Would it be reasonable to access the single elements e.g by row -> vector ->
element  and than multiply the elements. Or would that be to much of a
performance hit ?

You can certainly do it, but there's a faster way: Eigen allows you to directly access the elements in the array of matrix entries, by operator[]. You can take advantage of it here, i.e. do a single loop like

	for( int i = 0; i < size()*size(); i++ )
		result_matrix[i] = matrix1[i] * matrix2[i];

As a side-note: if you know at compile-time the size of your matrices and if this size isn't too big, you'll get much, much better performance with fixed-size matrices, i.e.

Matrix< float, Size > or Matrix4f instead of MatrixXf.

Benoit


Mail converted by MHonArc 2.6.19+ http://listengine.tuxfamily.org/