tumfpack.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 // STL
00023 #include <iostream>
00024 
00025 // UMFPACK
00026 #include <umfpack.h>
00027 
00028 // MechSys
00029 #include "util/exception.h"
00030 
00031 using std::cout;
00032 using std::endl;
00033 
00034 int main(int argc, char **argv) try
00035 {
00036     int    n = 5 ;
00037     int    Ap [ ] = {0, 2, 5, 9, 10, 12} ;
00038     int    Ai [ ] = { 0,  1,  0,   2,  4,  1,  2,  3,   4,  2,  1,  4} ;
00039     double Ax [ ] = {2., 3., 3., -1., 4., 4., -3., 1., 2., 2., 6., 1.} ;
00040     double b [ ] = {8., 45., -3., 3., 19.} ;
00041     double x [5] ;
00042 
00043     double *null = (double *) NULL ;
00044     int i ;
00045     void *Symbolic, *Numeric ;
00046     (void) umfpack_di_symbolic (n, n, Ap, Ai, Ax, &Symbolic, null, null) ;
00047     (void) umfpack_di_numeric (Ap, Ai, Ax, Symbolic, &Numeric, null, null) ;
00048     umfpack_di_free_symbolic (&Symbolic) ;
00049     (void) umfpack_di_solve (UMFPACK_A, Ap, Ai, Ax, x, b, Numeric, null, null) ;
00050     umfpack_di_free_numeric (&Numeric) ;
00051     for (i = 0 ; i < n ; i++) cout << "x [" << i << "] = " << x[i] << endl;
00052 
00053     return 0;
00054 }
00055 catch (Exception * e) //{{{ 
00056 {
00057     e->Cout();
00058     if (e->IsFatal()) {delete e; exit(1);}
00059     delete e;
00060 }
00061 catch (char const * m)
00062 {
00063     std::cout << "Fatal: " << m << std::endl;
00064     exit (1);
00065 }
00066 catch (...)
00067 {
00068     std::cout << "Some exception (...) ocurred\n";
00069 } //}}} 
00070 
00071 // vim:fdm=marker

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