tsymmv.cpp

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 #include "util/exception.h"
00032 
00033 using namespace std;
00034 using namespace LinAlg;
00035 
00036 int main() try
00037 {
00038     // =============================================================== Matrix x Vector
00039 
00040     cout << "\nSymmetric ==================================== Matrix x Vector\n";
00041     
00042     Matrix<REAL> A(5, "1 2 3 4 5", "12 13 14 15  23 24 25  34 35  45");
00043     Vector<REAL> X(5,"-1 -1  1 0 2");
00044     Vector<REAL> Y(5); Y.SetValues(1);
00045 
00046     cout << "A = \n" << A << endl;
00047     cout << "X = \n" << X << endl;
00048     cout << "Y = \n" << Y << endl;
00049     
00050     double a =  1.1;
00051     double b = -8.0;
00052     Symv(a,A,X,b,Y);
00053     cout << "Y := " << a << "*A*X + " << b << "*Y = \n" << Y << endl;
00054 
00055     return 0;
00056 }
00057 catch (Exception * e) //{{{ 
00058 {
00059     e->Cout();
00060     if (e->IsFatal()) {delete e; exit(1);}
00061     delete e;
00062 }
00063 catch (char const * m)
00064 {
00065     std::cout << "Fatal: " << m << std::endl;
00066     exit (1);
00067 }
00068 catch (...)
00069 {
00070     std::cout << "Some exception (...) ocurred\n";
00071 } //}}} 
00072 
00073 // vim:fdm=marker

Generated on Wed Jan 24 15:56:26 2007 for MechSys by  doxygen 1.4.7