PCL Lesson6:Eigen基础

#include "stdio.h"
#include <iostream>
#include <Eigen/Core>
#include <Eigen/LU>        //LU分解求逆
int main(int argc,char*argv[])
{
    Eigen::Matrix3d R = Eigen::Matrix3d::Random();
    Eigen::Matrix3d RInv = Eigen::Matrix3d::Random();
    Eigen::Matrix3d X = Eigen::Matrix3d::Random();
    Eigen::Vector3d f1 = Eigen::Vector3d::Random();  //3*1,转置f1.transpose()
    //R << 1,2,3,4,5,6,7,8,9;
    X << 1,1,1,0,1,0,0,0,1;
    f1 << 1,2,3;
    RInv = R.inverse();

    std::cout << "R =" << std::endl << R << std::endl; 
    std::cout << "R.transpose =" << std::endl << R.transpose() << std::endl; 
    std::cout << "R.inv =" << std::endl << RInv << std::endl; 

    std::cout << "R*R.inv =" << std::endl << R*RInv << std::endl; 

    std::cout << "R*X =" << std::endl << R*X << std::endl;  //3*3,3*3
    std::cout << "R*f1 =" << std::endl << R*f1 << std::endl; //3*3,3*1
    std::cout << "f1.transpose()*R" <<std::endl << f1.transpose()*R <<std::endl; //1*3,3*3
    
    printf("hello world !\n");
    return 1;
}

结果:
lx@lx-B5400:~/kdevelopProjects/demo_eigen/build$ ./demo_eigen
R =
0.680375 0.59688 -0.329554
-0.211234 0.823295 0.536459
0.566198 -0.604897 -0.444451
R.transpose =
0.680375 -0.211234 0.566198
0.59688 0.823295 -0.604897
-0.329554 0.536459 -0.444451
R.inv =
-0.198521 2.22739 2.8357
1.00605 -0.555135 -1.41603
-1.62213 3.59308 3.28973
RR.inv =
1 -2.22045e-16 0
1.73472e-16 1 1.11022e-16
1.38778e-17 0 1
R
X =
0.680375 1.27726 0.350821
-0.211234 0.612061 0.325225
0.566198 -0.0386988 0.121748
R*f1 =
0.885472
3.04473
-1.97695
f1.transpose()*R
1.9565 0.428778 -0.589988
hello world !

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值