TR-mbed 1.0
Loading...
Searching...
No Matches
init_matrix.hh
Go to the documentation of this file.
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 (unsigned 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 (unsigned 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>
52 A.resize(size);
53 for (unsigned int row=0; row<A.size() ; row++)
54 A[row].resize(size);
55 for (unsigned int row=0; row<A.size() ; row++){
56 A[row][row] = init_function(row,row);
57 for (unsigned 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
m col(1)
m row(1)
v resize(3)
Scalar Scalar int size
Definition benchVecAdd.cpp:17
Matrix< SCALARA, Dynamic, Dynamic, opt_A > A
Definition bench_gemm.cpp:48
#define BTL_DONT_INLINE
Definition btl.hh:38
set noclip points set clip one set noclip two set bar set border lt lw set xdata set ydata set zdata set x2data set y2data set boxwidth set dummy x
Definition gnuplot_common_settings.hh:12
#define X
Definition icosphere.cpp:20
BTL_DONT_INLINE void init_row(Vector &X, int size, int row)
Definition init_matrix.hh:28
BTL_DONT_INLINE void init_matrix(Vector &A, int size)
Definition init_matrix.hh:43
BTL_DONT_INLINE void init_matrix_symm(Matrix &A, int size)
Definition init_matrix.hh:51
std::ptrdiff_t j
Definition tut_arithmetic_redux_minmax.cpp:2