On Sun, May 30, 2010 at 5:39 AM, Manoj Rajagopalan
<rmanoj@xxxxxxxxx> wrote:
Hi eigen developers,
The following test program and output performs w=v*M; where w and v are Nx1
column vectors and M is NxN matrix. This statement, IMHO, should result in a
compile-time error since the product isn't defined. Instead, the effect seems
to be w = M.col(0) \kron v where \kron denotes tensor product: w is resized
to be (N^2)x1 column vector.
This brings me to another question: is there some way to disable automatic
right-side resizing during an assignment? This would help to trap bugs such
as the above. The automatic resizing is not always desirable.
Thanks,
Manoj
----------- Sample program and result --------------
#include <Eigen/Core>
#include <iostream>
using namespace Eigen;
using namespace std;
int main(void)
{
typedef Matrix<double,Dynamic,1> dvector;
typedef Matrix<double,Dynamic,Dynamic> dge_matrix;
int const N = 5;
dvector v(N);
for(int i=0;i<N;++i) v[i] = double(i+1);
dge_matrix M(N,N);
for(int j=0; j<N; ++j)
for(int i=0; i<N; ++i)
M(i,j) = double(10*(i+1)+(j+1));
dvector w(N);
w = v*M;
cout << "v' = " << v.transpose() << endl;
cout << "M =\n" << M << endl;
cout << "w' = " << w.transpose() << endl;
return 0;
}
v' = 1 2 3 4 5
M =
11 12 13 14 15
21 22 23 24 25
31 32 33 34 35
41 42 43 44 45
51 52 53 54 55
w' = 11 22 33 44 55 21 42 63 84 105 31 62 93 124 155 41 82 123
164 205 51 102 153 204 255