00001 /************************************************************************************* 00002 * MechSys - A C++ library to simulate (Continuum) Mechanical Systems * 00003 * Copyright (C) 2005 Dorival de Moraes Pedroso <dorival.pedroso at gmail.com> * 00004 * Copyright (C) 2005 Raul Dario Durand Farfan <raul.durand at gmail.com> * 00005 * * 00006 * This file is part of MechSys. * 00007 * * 00008 * MechSys is free software; you can redistribute it and/or modify it under the * 00009 * terms of the GNU General Public License as published by the Free Software * 00010 * Foundation; either version 2 of the License, or (at your option) any later * 00011 * version. * 00012 * * 00013 * MechSys is distributed in the hope that it will be useful, but WITHOUT ANY * 00014 * WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A * 00015 * PARTICULAR PURPOSE. See the GNU General Public License for more details. * 00016 * * 00017 * You should have received a copy of the GNU General Public License along with * 00018 * MechSys; if not, write to the Free Software Foundation, Inc., 51 Franklin Street, * 00019 * Fifth Floor, Boston, MA 02110-1301, USA * 00020 *************************************************************************************/ 00021 00022 #define _NMBFMT std::setw(12) << 00023 00024 #include <iostream> 00025 #include <cmath> 00026 #include <iomanip> 00027 00028 #include "linalg/lawrap.h" 00029 #include "linalg/matrix.h" 00030 #include "linalg/vector.h" 00031 00032 using namespace std; 00033 using namespace LinAlg; 00034 00035 int main() 00036 { 00037 // ================================================================= Linear Solver 00038 00039 cout << "\n============================================== Linear Solver\n"; 00040 00041 Matrix<REAL> A(5,5,"3 1 3 1 8 1 5 9 -2 4 2 6 5 0 -7 1 2 2 3 1 1 2 3 1 -1"); 00042 Vector<REAL> Y(5,"-1 -1 1 0 2"); 00043 00044 cout << "A = \n" << A << endl; 00045 cout << "Y = \n" << Y << endl; 00046 00047 if (Gesv(A,Y)==0) 00048 { 00049 cout << "Y := inv(A)*Y\n" << Y << endl; 00050 cout << "matrix A after solver = \n" << A << endl; 00051 } 00052 else 00053 cout << "ERROR: Impossible to solve [A]{X} = {Y} !\n"; 00054 00055 return 0; 00056 }