tvv.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/vector.h"
00030 #include "util/exception.h"
00031 
00032 using namespace std;
00033 using namespace LinAlg;
00034 
00035 int main() try
00036 {
00037 
00038     double a=2.0;
00039     Vector<REAL> X(5, "0 1 2 3 4");
00040     Vector<REAL> Y(5, "0 1 2 3 4");
00041 
00042     cout << "a = " << a << endl;
00043     cout << "X = " << X << endl;
00044     cout << "Y = " << Y << endl;
00045 
00046     cout << "-------------------------------------------------------------------------------- Scal\n";
00047     Scal(a, X);
00048     cout << "X <- a*X  = " << X << endl;
00049 
00050     cout << "-------------------------------------------------------------------------------- Copy\n";
00051     Copy(X, Y);
00052     cout << "Y <- X  = " << Y << endl;
00053 
00054     cout << "-------------------------------------------------------------------------------- Axpy\n";
00055     Axpy(a, X, Y);
00056     cout << "Y <- a*X + Y   = " << Y << endl;
00057 
00058     cout << "--------------------------------------------------------------------------------- Dot\n";
00059     cout << "s <- X dot Y  = " << Dot(X,Y) << endl;
00060     Dot(X, Y);
00061 
00062     return 0;
00063 }
00064 catch (Exception * e) //{{{ 
00065 {
00066     e->Cout();
00067     if (e->IsFatal()) {delete e; exit(1);}
00068     delete e;
00069 }
00070 catch (char const * m)
00071 {
00072     std::cout << "Fatal: " << m << std::endl;
00073     exit (1);
00074 }
00075 catch (...)
00076 {
00077     std::cout << "Some exception (...) ocurred\n";
00078 } //}}} 
00079 
00080 // vim:fdm=marker

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