init_matrix.hh
Go to the documentation of this file.
00001 //=====================================================
00002 // File   :  init_matrix.hh
00003 // Author :  L. Plagne <laurent.plagne@edf.fr)>
00004 // Copyright (C) EDF R&D,  lun sep 30 14:23:19 CEST 2002
00005 //=====================================================
00006 //
00007 // This program is free software; you can redistribute it and/or
00008 // modify it under the terms of the GNU General Public License
00009 // as published by the Free Software Foundation; either version 2
00010 // of the License, or (at your option) any later version.
00011 //
00012 // This program is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License for more details.
00016 // You should have received a copy of the GNU General Public License
00017 // along with this program; if not, write to the Free Software
00018 // Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA  02111-1307, USA.
00019 //
00020 #ifndef INIT_MATRIX_HH
00021 #define INIT_MATRIX_HH
00022 
00023 // The Vector class must satisfy the following part of STL vector concept :
00024 //            resize() method
00025 //            [] operator for setting element
00026 //            value_type defined
00027 template<double init_function(int,int), class Vector>
00028 BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
00029 
00030   X.resize(size);
00031 
00032   for (int j=0;j<X.size();j++){
00033     X[j]=typename Vector::value_type(init_function(row,j));
00034   }
00035 }
00036 
00037 
00038 // Matrix is a Vector of Vector
00039 // The Matrix class must satisfy the following part of STL vector concept :
00040 //            resize() method
00041 //            [] operator for setting rows
00042 template<double init_function(int,int),class Vector>
00043 BTL_DONT_INLINE void init_matrix(Vector &  A, int size){
00044   A.resize(size);
00045   for (int row=0; row<A.size() ; row++){
00046     init_row<init_function>(A[row],size,row);
00047   }
00048 }
00049 
00050 template<double init_function(int,int),class Matrix>
00051 BTL_DONT_INLINE void init_matrix_symm(Matrix&  A, int size){
00052   A.resize(size);
00053   for (int row=0; row<A.size() ; row++)
00054     A[row].resize(size);
00055   for (int row=0; row<A.size() ; row++){
00056     A[row][row] = init_function(row,row);
00057     for (int col=0; col<row ; col++){
00058       double x = init_function(row,col);
00059       A[row][col] = A[col][row] = x;
00060     }
00061   }
00062 }
00063 
00064 #endif


re_vision
Author(s): Dorian Galvez-Lopez
autogenerated on Sun Jan 5 2014 11:31:25