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

Problems with simple multiplication

Tags: None
(comma "," separated)
fry
Registered Member
Posts
2
Karma
0

Problems with simple multiplication

Tue Aug 18, 2009 8:41 am
I'm using Visual Studio 2008 but I'm doing something wrong when I want to multiplicate two vectors or matrices.

Every time I compile the following code I'll get a warning:

VectorXd v1;
VectorXd v2;
MatrixXd m(2,2);

v1.setZero(2);
v2.setZero(2);

v1[0]=1;
v1[1]=2;
v2[0]=0.5;
v2[1]=0.25;

m=v1*v2.transpose();


warning:

\eigen2\eigen\src\core\matrix.h(510) : warning C4305: 'specialization' : truncation from 'const unsigned int' to 'bool'

eigen2\eigen\src\core\matrix.h(261) : see reference to function template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols> &Eigen::Matrix<_Scalar,_Rows,_Cols>::_set<Eigen::Product<LhsNested,RhsNested,ProductMode>>(const Eigen::MatrixBase<Derived> &)' being compiled
1> with
1> [
1> _Scalar=double,
1> _Rows=10000,
1> _Cols=10000,
1> LhsNested=const Eigen::Matrix<double,10000,1> &,
1> RhsNested=const Eigen::Transpose<Eigen::Matrix<double,10000,1>> &,
1> ProductMode=0,
1> Derived=Eigen::Product<const Eigen::Matrix<double,10000,1> &,const Eigen::Transpose<Eigen::Matrix<double,10000,1>> &,0>
1> ]

eigentest.cpp(33) : see reference to function template instantiation 'Eigen::Matrix<_Scalar,_Rows,_Cols> &Eigen::Matrix<_Scalar,_Rows,_Cols>::operator =<Eigen::Product<LhsNested,RhsNested,ProductMode>>(const Eigen::MatrixBase<Derived> &)' being compiled
1> with
1> [
1> _Scalar=double,
1> _Rows=10000,
1> _Cols=10000,
1> LhsNested=const Eigen::Matrix<double,10000,1> &,
1> RhsNested=const Eigen::Transpose<Eigen::Matrix<double,10000,1>> &,
1> ProductMode=0,
1> Derived=Eigen::Product<const Eigen::Matrix<double,10000,1> &,const Eigen::Transpose<Eigen::Matrix<double,10000,1>> &,0>
1> ]

So, this tells me that the memory for a matrix of the size 10000*10000 is allocated, doesn't it?
But I know that the product of the two vectors is a 2*2 matrix only.
All I want is a multiplication without a warning.

Thanks a lot for your help
User avatar
bjacob
Registered Member
Posts
658
Karma
3
Thanks for the report, I just committed a fix (well hopefully it fixes it, i don't have MSVC to try).

Can you please try the 2.0 branch and tell me if it works? as explained here,
http://eigen.tuxfamily.org/index.php?ti ... e#Download

So, this tells me that the memory for a matrix of the size 10000*10000 is allocated, doesn't it?


No, don't worry :) 10000 is just the special value for "dynamic", that is, "not fixed at compile-time", and only as a template parameter. You don't have to worry about this value, it doesn't have any impact on what Eigen does.

You can check for yourself in any memory debugger that no large memory allocation occured ;)


Join us on Eigen's IRC channel: #eigen on irc.freenode.net
Have a serious interest in Eigen? Then join the mailing list!
fry
Registered Member
Posts
2
Karma
0
Wow, that was quick!

I just tried it with the 2.0 branch and it works like a charm now. No warning is generated anymore. And yeah, you are right, I checked the memory allocation and there isn't space allocated for the 10000*10000 scalars.

Thanks a lot for this fast and competent answer!


Bookmarks



Who is online

Registered users: Bing [Bot], claydoh, gfielding, Google [Bot], markhm, rblackwell, sethaaaa, Sogou [Bot], Yahoo [Bot]