# include # include using namespace Eigen; using namespace std; int main ( ); void version1 ( ); void version2 ( ); //****************************************************************************80 int main ( ) //****************************************************************************80 // // Purpose: // // MAIN is the main program for EIGEN_TEST02. // // Modified: // // 04 March 2017 // { cout << "\n"; cout <<"EIGEN_TEST02:\n"; cout << " Define matrix m, vector v, and product m*v.\n"; version1 ( ); version2 ( ); // // Terminate. // cout << "\n"; cout <<"EIGEN_TEST02:\n"; cout << " Normal end of execution.\n"; return 0; } //****************************************************************************80 void version1 ( ) //****************************************************************************80 // // Purpose: // // VERSION1 uses a variable spatial dimension. // // Modified: // // 04 March 2017 // { srand ( 123456789 ); MatrixXd m = MatrixXd::Random ( 3, 3 ); m = ( m + MatrixXd::Constant ( 3, 3, 1.2 ) ) * 50; cout << "\n"; cout << "VERSION1:\n"; cout << " Use a variable spatial dimension.\n"; cout << "\n"; cout << " m: " << "\n"; cout << m << "\n"; VectorXd v(3); v << 1, 2, 3; cout << "\n"; cout << " v: " << "\n"; cout << v << "\n"; cout << "\n"; cout << " m * v:\n"; cout << m * v << "\n"; return; } //****************************************************************************80 void version2 ( ) //****************************************************************************80 // // Purpose: // // VERSION2 uses dimension 3 explicitly. // // Modified: // // 04 March 2017 // { srand ( 123456789 ); Matrix3d m = Matrix3d::Random ( ); m = ( m + Matrix3d::Constant ( 1.2 ) ) * 50; cout << "\n"; cout << "VERSION2:\n"; cout << " Use dimension 3 explicitly.\n"; cout << "\n"; cout << " m: " << "\n"; cout << m << "\n"; Vector3d v(1,2,3); cout << "\n"; cout << " v: " << "\n"; cout << v << "\n"; cout << "\n"; cout << " m * v:\n"; cout << m * v << "\n"; return; }