add missing code snippets for newer Matrix methods and PartialLU::solve()

This commit is contained in:
Benoit Jacob 2009-06-25 00:57:51 +02:00
parent 03ad303d14
commit 903acf0d5c
11 changed files with 36 additions and 1 deletions

View File

@ -274,7 +274,7 @@ EIGEN_STRONG_INLINE Derived& MatrixBase<Derived>::setConstant(const Scalar& valu
*
* \only_for_vectors
*
* Example: \include Matrix_set_int.cpp
* Example: \include Matrix_setConstant_int.cpp
* Output: \verbinclude Matrix_setConstant_int.out
*
* \sa MatrixBase::setConstant(const Scalar&), setConstant(int,int,const Scalar&), class CwiseNullaryOp, MatrixBase::Constant(const Scalar&)

View File

@ -0,0 +1,3 @@
VectorXf v;
v.setConstant(3, 5);
cout << v << endl;

View File

@ -0,0 +1,3 @@
MatrixXf m;
m.setConstant(3, 3, 5);
cout << m << endl;

View File

@ -0,0 +1,3 @@
MatrixXf m;
m.setIdentity(3, 3);
cout << m << endl;

View File

@ -0,0 +1,3 @@
VectorXf v;
v.setOnes(3);
cout << v << endl;

View File

@ -0,0 +1,3 @@
MatrixXf m;
m.setOnes(3, 3);
cout << m << endl;

View File

@ -0,0 +1,3 @@
VectorXf v;
v.setRandom(3);
cout << v << endl;

View File

@ -0,0 +1,3 @@
MatrixXf m;
m.setRandom(3, 3);
cout << m << endl;

View File

@ -0,0 +1,3 @@
VectorXf v;
v.setZero(3);
cout << v << endl;

View File

@ -0,0 +1,3 @@
MatrixXf m;
m.setZero(3, 3);
cout << m << endl;

View File

@ -0,0 +1,8 @@
MatrixXd A = MatrixXd::Random(3,3);
MatrixXd B = MatrixXd::Random(3,2);
cout << "Here is the invertible matrix A:" << endl << A << endl;
cout << "Here is the matrix B:" << endl << B << endl;
MatrixXd X;
if(A.lu().solve(B, &X))
cout << "Here is the (unique) solution X to the equation AX=B:" << endl << X << endl;
cout << "Relative error: " << (A*X-B).norm() / B.norm() << endl;