使用eigen库:
求行列式:
#include <iostream> #include <Eigen/Dense> using namespace std; using namespace Eigen; int main() { Matrix2d c; c << 1, 2, 3, 4; //转置、伴随 std::cout<<c<<std::endl<<std::endl; std::cout<<"转置\n"<<c.transpose()<<std::endl<<std::endl; std::cout<<"伴随\n"<<c.adjoint()<<std::endl<<std::endl; //逆矩阵、行列式 std::cout << "行列式: " << c.determinant() << std::endl; std::cout << "逆矩阵\n" << c.inverse() << std::endl; }
原文地址:https://www.cnblogs.com/wxl845235800/p/9027005.html
时间: 2024-11-02 14:08:10