eigen C 不能反向matrixxd
EIGEN C++ Cannot Inverse MatrixXd
我在下面尝试运行此代码,而逆执行此代码:
#include <iostream>
#include <Eigen/Dense>
using namespace std;
using namespace Eigen;
int main()
{
Matrix2d A;
A << 3, 5,
-7, 2;
cout << "Here is the matrix A:n" << A << endl;
cout << "The determinant of A is " << A.determinant() << endl;
cout << "The inverse of A is:n" << A.inverse() << endl;
}
但是我正在尝试倒数矩阵,这是可能的吗?
我正在尝试:
MatrixXd m(2,2);
m << 3, 5,
-7, 2;
cout << m.inverse() << endl;
这是错误:在此处输入图像描述
谢谢!
使用MatrixXd
与Matrix2d
相同的方式,除非您必须告诉它制作矩阵多大。这是VS 2013和Eigen 3.3.4
#include <iostream>
#include <EigenDense>
using namespace Eigen;
int main(int argc, char * argv[]){
Matrix2d A;
A << 3, 5, -7, 2;
std::cout << "Here is the matrix A:n" << A << 'n';
std::cout << "The determinant of A is:" << A.determinant() << 'n';
std::cout << "The inverse of A is:n" << A.inverse() << 'n';
MatrixXd B(5, 5);
B = MatrixXd::Random(5, 5);
std::cout << "Here is the matrix B:n" << B << 'n';
std::cout << "The determinant of B is:" << B.determinant() << 'n';
std::cout << "The inverse of B is:n" << B.inverse() << 'n';
return 0;
}
B
可以是您想要的任何大小。所有MatrixXd
都是Matrix<double, Dynamic, Dynamic>
的Typedef。你也可以用
Matrix<double, 5, 5> C = Matrix<double, 5, 5>::Random(5, 5);
如果您想要比这更好的解释,则必须包括您正在遇到的实际错误。
相关文章:
- C++我的数学有什么问题,为什么我的代码不能正确循环
- 为什么在没有显式默认构造函数的情况下,将另一个结构封装在联合中作为成员的结构不能编译
- 为什么我的for循环不能正确获取argv
- 不能在初始值设定项列表中将非常量表达式从类型 'int' 缩小到'unsigned long long'
- 为什么我不能在 FOR LOOP 中使用 i/10,C++?
- 为什么我不能在不创建字符串变量的情况下使用函数的字符串输出
- 为什么模板类中的对象不能返回值
- 为什么我不能在一个类的不同行中声明和定义成员变量?
- 为什么我不能在 C++ 中的特定函数重载中调用同一函数的任何其他重载?
- ld:bind_at_load和-bitcode_bundle(Xcode设置ENABLE_bitcode=YES)不能
- 数组长度,为什么从命令行获取时不能使用它?
- Windows/Cygwin - 不能使用 pybind11 - 犯错误
- 为什么我不能使用 EGL 创建无头 OpenGl 上下文?
- 递归模板化函数不能分配给具有常量限定类型"const tt &"的变量"state"
- 为什么我不能将一个对象push_back到属于另一个类的对象向量中?
- 为什么我不能将 rand() 与数组的大小一起使用?
- 为什么虚函数不能是静态的和全局的?
- 为什么我不能在 while 循环中创建线程?
- 为什么这个音频包络不能通过开关的情况?
- eigen C 不能反向matrixxd