action_lu_decomp.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  action_lu_decomp.hh
00003 // Copyright (C) 2008 Gael Guennebaud <gael.guennebaud@inria.fr>
00004 //=====================================================
00005 //
00006 // This program is free software; you can redistribute it and/or
00007 // modify it under the terms of the GNU General Public License
00008 // as published by the Free Software Foundation; either version 2
00009 // of the License, or (at your option) any later version.
00010 //
00011 // This program is distributed in the hope that it will be useful,
00012 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00013 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00014 // GNU General Public License for more details.
00015 // You should have received a copy of the GNU General Public License
00016 // along with this program; if not, write to the Free Software
00017 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00018 //
00019 #ifndef ACTION_LU_DECOMP
00020 #define ACTION_LU_DECOMP
00021 #include "utilities.h"
00022 #include "STL_interface.hh"
00023 #include <string>
00024 #include "init/init_function.hh"
00025 #include "init/init_vector.hh"
00026 #include "init/init_matrix.hh"
00027 
00028 using namespace std;
00029 
00030 template<class Interface>
00031 class Action_lu_decomp {
00032 
00033 public :
00034 
00035   // Ctor
00036 
00037   Action_lu_decomp( int size ):_size(size)
00038   {
00039     MESSAGE("Action_lu_decomp Ctor");
00040 
00041     // STL vector initialization
00042     init_matrix<pseudo_random>(X_stl,_size);
00043 
00044     init_matrix<null_function>(C_stl,_size);
00045     init_matrix<null_function>(resu_stl,_size);
00046 
00047     // generic matrix and vector initialization
00048     Interface::matrix_from_stl(X_ref,X_stl);
00049     Interface::matrix_from_stl(X,X_stl);
00050     Interface::matrix_from_stl(C,C_stl);
00051 
00052     _cost = 2.0*size*size*size/3.0 + size*size;
00053   }
00054 
00055   // invalidate copy ctor
00056 
00057   Action_lu_decomp( const  Action_lu_decomp & )
00058   {
00059     INFOS("illegal call to Action_lu_decomp Copy Ctor");
00060     exit(1);
00061   }
00062 
00063   // Dtor
00064 
00065   ~Action_lu_decomp( void ){
00066 
00067     MESSAGE("Action_lu_decomp Dtor");
00068 
00069     // deallocation
00070     Interface::free_matrix(X_ref,_size);
00071     Interface::free_matrix(X,_size);
00072     Interface::free_matrix(C,_size);
00073   }
00074 
00075   // action name
00076 
00077   static inline std::string name( void )
00078   {
00079     return "complete_lu_decomp_"+Interface::name();
00080   }
00081 
00082   double nb_op_base( void ){
00083     return _cost;
00084   }
00085 
00086   inline void initialize( void ){
00087     Interface::copy_matrix(X_ref,X,_size);
00088   }
00089 
00090   inline void calculate( void ) {
00091       Interface::lu_decomp(X,C,_size);
00092   }
00093 
00094   void check_result( void ){
00095     // calculation check
00096     Interface::matrix_to_stl(C,resu_stl);
00097 
00098 //     STL_interface<typename Interface::real_type>::lu_decomp(X_stl,C_stl,_size);
00099 //
00100 //     typename Interface::real_type error=
00101 //       STL_interface<typename Interface::real_type>::norm_diff(C_stl,resu_stl);
00102 //
00103 //     if (error>1.e-6){
00104 //       INFOS("WRONG CALCULATION...residual=" << error);
00105 //       exit(0);
00106 //     }
00107 
00108   }
00109 
00110 private :
00111 
00112   typename Interface::stl_matrix X_stl;
00113   typename Interface::stl_matrix C_stl;
00114   typename Interface::stl_matrix resu_stl;
00115 
00116   typename Interface::gene_matrix X_ref;
00117   typename Interface::gene_matrix X;
00118   typename Interface::gene_matrix C;
00119 
00120   int _size;
00121   double _cost;
00122 };
00123 
00124 #endif


libicr
Author(s): Robert Krug
autogenerated on Mon Jan 6 2014 11:32:28