matrixFunctions.cpp

00001 /***************************************************************************
00002  *   Copyright (C) 2005 by Nestor Aguirre                                  *
00003  *   nfaguirrec@unal.edu.co                                                *
00004  *                                                                         *
00005  *   This program is free software; you can redistribute it and/or modify  *
00006  *   it under the terms of the GNU General Public License as published by  *
00007  *   the Free Software Foundation; either version 2 of the License, or     *
00008  *   (at your option) any later version.                                   *
00009  *                                                                         *
00010  *   This program is distributed in the hope that it will be useful,       *
00011  *   but WITHOUT ANY WARRANTY; without even the implied warranty of        *
00012  *   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the         *
00013  *   GNU General Public License for more details.                          *
00014  *                                                                         *
00015  *   You should have received a copy of the GNU General Public License     *
00016  *   along with this program; if not, write to the                         *
00017  *   Free Software Foundation, Inc.,                                       *
00018  *   59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.             *
00019  ***************************************************************************/
00020 
00021 // C++
00022 #include <fstream>
00023 #include <math.h>
00024 using namespace std;
00025 
00026 // Project
00027 #include <SawMatrix.h>
00028 #include <SawVector.h>
00029 #include <SawVectorList.h>
00030 #include <SawUtils.h>
00031 
00032 double myFunction1( double x ){ return pow( x, 0.5 ) ; }
00033 double myFunction2( double x ){ return sin( x ) ; }
00034 
00035 int main(int argc, char *argv[]){
00036         
00037         cout << "************************************************" << endl ;
00038         cout << "*                                              *" << endl ;
00039         cout << "*            MATRIX FUNCTIONS TEST             *" << endl ;
00040         cout << "*             Nestor Aguirre  2006             *" << endl ;
00041         cout << "*            nfaguirrec@unal.edu.co            *" << endl ;
00042         cout << "*                                              *" << endl ;
00043         cout << "************************************************" << endl ;
00044         cout << endl ;
00045         
00046         /**********************************************************
00047         * Se inicializa la matriz cargandola desde un stream
00048         */
00049         SawMatrix matrix( 7, 7 ) ;
00050         ifstream file("overlapH2O.data") ;
00051         file >> matrix ;
00052         file.close() ;
00053         
00054         cout << endl ;
00055         cout << "-----------------------------------------" << endl ;
00056         cout << "   Usando funciones predefinidas en Saw  " << endl ;
00057         cout << "-----------------------------------------" << endl ;
00058         cout << "A = " << matrix << endl ;
00059         cout << "A^(0.5) = " << SawMatrix::pow( matrix, -0.5 ) << endl ;
00060         cout << "sin(A) = " << SawMatrix::sin( matrix ) << endl ;
00061         
00062         cout << "-----------------------------------------" << endl ;
00063         cout << "   Usando SawMatrix::genericFunction()   " << endl ;
00064         cout << "-----------------------------------------" << endl ;
00065         cout << endl ;
00066         cout << "A^(-0.5) = " << SawMatrix::genericFunction( matrix, *myFunction1 ) << endl ;
00067         cout << "sin(A) = " << SawMatrix::genericFunction( matrix, *myFunction2 ) << endl ;
00068         
00069         return EXIT_SUCCESS;
00070 }

Generado el Sun Jul 22 18:05:41 2007 para SAW por  doxygen 1.5.1