c++计算eigen随笔(4)-y=xb+e

#include <iostream>
#include <Eigen/Dense>
#include <ctime>
using namespace  Eigen;
using namespace std;
 
int main()
{  
VectorXd e =  VectorXd::Random(2)*3;
cout << " e:" << endl << e << endl;


VectorXd b =  VectorXd::Random(5)*18;
cout << " b:" << endl << b << endl;

MatrixXd  x =  MatrixXd::Random(2,5)*100;
cout << " x:" << endl << x << endl;




MatrixXd  y = x*b+e;
cout << " y:" << endl << y << endl;
}
 e:
-2.99995
-2.21077
 b:
 9.20179
 -1.4886
 1.17962
-10.1175
-16.3064
 x:
 35.7729  86.9386  3.88327 -93.0856  5.94004
 35.8593 -23.2996  66.1931 -89.3077  34.2299
 y:
1049.27
788.138
Hit any key to continue...
发布了385 篇原创文章 · 获赞 13 · 访问量 5万+

猜你喜欢

转载自blog.csdn.net/AI_LX/article/details/104321278