标签:http os for sp on ad ef size bs
MatrixXd m (4, 6);
for (int i = 0; i < m.size(); ++i)
m (i) = i;
MatrixXd mc = m;/// 已经是深度拷贝
////// 协方差矩阵
Eigen::MatrixXd cov( Eigen::MatrixXd m ){
MatrixXd centered = m.rowwise() - m.colwise().mean();
return (centered.adjoint() * centered) / double(m.rows());
}
//////Kronecker tensor product
Eigen::MatrixXd kron( Eigen::MatrixXd m1, Eigen::MatrixXd m2 ){
int m1R,m1C,m2R,m2C;
m1R = m1.rows();
m1C = m1.cols();
m2R = m2.rows();
m2C = m2.cols();
Eigen::MatrixXd m3(m1R*m2R,m1C*m2C);
for (int i = 0; i < m1C; i++) {
for (int j = 0; j < m1R; j++) {
m3.block(i*m2R, j*m2C, m2R, m2C ) = m1(i,j)*m2;
}
}
return m3;
}
//// 将矩阵m的前 rowNum 行 转换为一列
Eigen::MatrixXd row2vector( Eigen::MatrixXd m, int rowNum ){
int colNum = m.cols();
Eigen::MatrixXd mt = m.transpose();
MatrixXd v;
v = Map<MatrixXd>( mt.leftCols(rowNum).data(),rowNum*colNum, 1 );
return v;
}
很有意义的参考文档
Matlab Vs Eigen
http://eigen.tuxfamily.org/dox-devel/AsciiQuickReference.txt
据说很快的SVD---redsvd
https://code.google.com/p/redsvd/
标签:http os for sp on ad ef size bs
原文地址:http://www.cnblogs.com/jalps/p/4013567.html