source: pacpussensors/trunk/Vislab/lib3dv/eigen/bench/btl/generic_bench/init/init_matrix.hh@ 136

Last change on this file since 136 was 136, checked in by ldecherf, 7 years ago

Doc

File size: 2.2 KB
Line 
1//=====================================================
2// File : init_matrix.hh
3// Author : L. Plagne <laurent.plagne@edf.fr)>
4// Copyright (C) EDF R&D, lun sep 30 14:23:19 CEST 2002
5//=====================================================
6//
7// This program is free software; you can redistribute it and/or
8// modify it under the terms of the GNU General Public License
9// as published by the Free Software Foundation; either version 2
10// of the License, or (at your option) any later version.
11//
12// This program is distributed in the hope that it will be useful,
13// but WITHOUT ANY WARRANTY; without even the implied warranty of
14// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15// GNU General Public License for more details.
16// You should have received a copy of the GNU General Public License
17// along with this program; if not, write to the Free Software
18// Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA.
19//
20#ifndef INIT_MATRIX_HH
21#define INIT_MATRIX_HH
22
23// The Vector class must satisfy the following part of STL vector concept :
24// resize() method
25// [] operator for setting element
26// value_type defined
27template<double init_function(int,int), class Vector>
28BTL_DONT_INLINE void init_row(Vector & X, int size, int row){
29
30 X.resize(size);
31
32 for (int j=0;j<X.size();j++){
33 X[j]=typename Vector::value_type(init_function(row,j));
34 }
35}
36
37
38// Matrix is a Vector of Vector
39// The Matrix class must satisfy the following part of STL vector concept :
40// resize() method
41// [] operator for setting rows
42template<double init_function(int,int),class Vector>
43BTL_DONT_INLINE void init_matrix(Vector & A, int size){
44 A.resize(size);
45 for (int row=0; row<A.size() ; row++){
46 init_row<init_function>(A[row],size,row);
47 }
48}
49
50template<double init_function(int,int),class Matrix>
51BTL_DONT_INLINE void init_matrix_symm(Matrix& A, int size){
52 A.resize(size);
53 for (int row=0; row<A.size() ; row++)
54 A[row].resize(size);
55 for (int row=0; row<A.size() ; row++){
56 A[row][row] = init_function(row,row);
57 for (int col=0; col<row ; col++){
58 double x = init_function(row,col);
59 A[row][col] = A[col][row] = x;
60 }
61 }
62}
63
64#endif
Note: See TracBrowser for help on using the repository browser.