次のコードがあります。
Eigen::MatrixXf aMatrix( 3, 5 );
aMatrix <<
1, 0, 1, 0, 1,
0, 1, 0, 1, 0,
1, 1, 1, 1, 1;
Eigen::VectorXf aVector( 5 );
aVector << 3, 4, 5, 6, 7;
cout << aMatrix.cwiseProduct( aVector.replicate( 1, aMatrix.rows() ).transpose() ) << endl;
出力:
3 0 5 0 7
0 4 0 6 0
3 4 5 6 7
replicate()
呼び出しを使用するよりも効率的にこれを達成する方法はありますか?