首页 > 其他分享 >Eigen矩阵/向量操作

Eigen矩阵/向量操作

时间:2023-03-01 20:35:45浏览次数:64  
标签:__ Eigen 矩阵 https 向量 eigen

应知应会

  • Eigen中矩阵和向量相加,没有Python中的广播机制
  • Eigen中的索引时是小括号()而不是方括号[],不同于python中的numpy

参考资料

Block操作

Eigen::MatrixXf m(4,4);
m <<  1, 2, 3, 4,
        5, 6, 7, 8,
        9,10,11,12,
        13,14,15,16;
std::cout << "Block in the middle" << std::endl;
std::cout << m.block<2,2>(1,1) << std::endl << std::endl;
for (int i = 1; i <= 4; ++i)
{
    std::cout << "Block of size " << i << "x" << i << std::endl;
    std::cout << m.block(0,0,i,i) << std::endl << std::endl;
}
//    Eigen::Vector2f vec(1, 2);
//    std::cout << "vector.norm(): " << vec.norm() << std::endl;
//      vector.norm(): 2.23607

In the above example the .block() function was employed as a rvalue, i.e. it was only read from. However, blocks can also be used as lvalues, meaning that you can assign to a block.

参考资料

https://eigen.tuxfamily.org/dox/group__TutorialBlockOperations.html

标签:__,Eigen,矩阵,https,向量,eigen
From: https://www.cnblogs.com/Todd-Qi/p/17105384.html

相关文章