我想解决一个线性方程Ax = b使用特征的A作为平方2D矢量的能力。我有A和B分别作为基于C++的2D矢量和1D矢量。但是,我无法找到将它们的值传递给特征格式矩阵和向量的方法。你能让我如何以Eigen格式复制变量吗? 此外,开始时应该包含哪些可以使用Map类作为可能的溶剂? 下面是代码:将矢量的值传递给特征库格式
#include <iostream>
#include <vector>
#include "Eigen/Dense"
using namespace std;
using namespace Eigen;
int main()
{
// Let's consider that the A and b are following CPP based vectors:
vector<vector<double>> mainA= { { 10.,11.,12. },{ 13.,14.,15. },{ 16.,17.,18. } };
vector<double> mainB = { 2.,5.,8. };
// ??? Here I need to do something to pass the values to the following Eigen
//format matrix and vector
MatrixXf A;
VectorXf b;
cout << "Here is the matrix A:\n" << A << endl;
cout << "Here is the vector b:\n" << b << endl;
Vector3f x = A.colPivHouseholderQr().solve(b);
cout << "The solution is:\n" << x << endl;
}
为什么不*只使用特征类型?为什么你需要C++向量? –
@Some程序员伙计原因是目前我有现有的载体,我需要为我的操作使用这些值! – ReA
我在这里找到了一些东西:但不知道如何正确使用它,我应该在开始时包含什么! –
ReA