tiny_blitz_interface.hh
Go to the documentation of this file.
1 //=====================================================
2 // File : tiny_blitz_interface.hh
3 // Author : L. Plagne <laurent.plagne@edf.fr)>
4 // Copyright (C) EDF R&D, lun sep 30 14:23:30 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 TINY_BLITZ_INTERFACE_HH
21 #define TINY_BLITZ_INTERFACE_HH
22 
23 #include "blitz/array.h"
24 #include "blitz/tiny.h"
25 #include "blitz/tinymat.h"
26 #include "blitz/tinyvec.h"
27 #include <blitz/tinyvec-et.h>
28 
29 #include <vector>
30 
31 BZ_USING_NAMESPACE(blitz)
32 
33 template<class real, int SIZE>
35 {
36 
37 public :
38 
39  typedef real real_type ;
40 
41  typedef std::vector<real> stl_vector;
42  typedef std::vector<stl_vector > stl_matrix;
43 
44  typedef TinyVector<real,SIZE> gene_vector;
45  typedef TinyMatrix<real,SIZE,SIZE> gene_matrix;
46 
47  static inline std::string name() { return "tiny_blitz"; }
48 
49  static void free_matrix(gene_matrix & A, int N){}
50 
51  static void free_vector(gene_vector & B){}
52 
53  static inline void matrix_from_stl(gene_matrix & A, stl_matrix & A_stl){
54  for (int j=0; j<A_stl.size() ; j++)
55  for (int i=0; i<A_stl[j].size() ; i++)
56  A(i,j)=A_stl[j][i];
57  }
58 
59  static inline void vector_from_stl(gene_vector & B, stl_vector & B_stl){
60  for (int i=0; i<B_stl.size() ; i++)
61  B(i) = B_stl[i];
62  }
63 
64  static inline void vector_to_stl(gene_vector & B, stl_vector & B_stl){
65  for (int i=0; i<B_stl.size() ; i++)
66  B_stl[i] = B(i);
67  }
68 
69  static inline void matrix_to_stl(gene_matrix & A, stl_matrix & A_stl){
70  int N = A_stl.size();
71  for (int j=0;j<N;j++)
72  {
73  A_stl[j].resize(N);
74  for (int i=0;i<N;i++)
75  A_stl[j][i] = A(i,j);
76  }
77  }
78 
79  static inline void copy_matrix(const gene_matrix & source, gene_matrix & cible, int N){
80  for (int j=0;j<N;j++)
81  for (int i=0;i<N;i++)
82  cible(i,j) = source(i,j);
83  }
84 
85  static inline void copy_vector(const gene_vector & source, gene_vector & cible, int N){
86  for (int i=0;i<N;i++){
87  cible(i) = source(i);
88  }
89  }
90 
91  static inline void matrix_matrix_product(const gene_matrix & A, const gene_matrix & B, gene_matrix & X, int N){
92  X = product(A,B);
93  }
94 
95  static inline void matrix_vector_product(gene_matrix & A, gene_vector & B, gene_vector & X, int N){
96  X = product(A,B);
97  }
98 
99  static inline void axpy(const real coef, const gene_vector & X, gene_vector & Y, int N){
100  Y += coef * X;
101  }
102 
103 };
104 
105 
106 #endif
tiny_blitz_interface::matrix_vector_product
static void matrix_vector_product(gene_matrix &A, gene_vector &B, gene_vector &X, int N)
Definition: tiny_blitz_interface.hh:95
tiny_blitz_interface::gene_vector
TinyVector< real, SIZE > gene_vector
Definition: tiny_blitz_interface.hh:44
gtsam::Y
GaussianFactorGraphValuePair Y
Definition: HybridGaussianProductFactor.cpp:29
tiny_blitz_interface::name
static std::string name()
Definition: tiny_blitz_interface.hh:47
tiny_blitz_interface::matrix_to_stl
static void matrix_to_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: tiny_blitz_interface.hh:69
B
Definition: test_numpy_dtypes.cpp:299
E1::B
@ B
tiny_blitz_interface::free_matrix
static void free_matrix(gene_matrix &A, int N)
Definition: tiny_blitz_interface.hh:49
X
#define X
Definition: icosphere.cpp:20
tiny_blitz_interface::axpy
static void axpy(const real coef, const gene_vector &X, gene_vector &Y, int N)
Definition: tiny_blitz_interface.hh:99
tiny_blitz_interface::free_vector
static void free_vector(gene_vector &B)
Definition: tiny_blitz_interface.hh:51
tiny_blitz_interface::stl_vector
std::vector< real > stl_vector
Definition: tiny_blitz_interface.hh:41
A
Definition: test_numpy_dtypes.cpp:298
tiny_blitz_interface::copy_matrix
static void copy_matrix(const gene_matrix &source, gene_matrix &cible, int N)
Definition: tiny_blitz_interface.hh:79
j
std::ptrdiff_t j
Definition: tut_arithmetic_redux_minmax.cpp:2
tiny_blitz_interface
Definition: tiny_blitz_interface.hh:34
tiny_blitz_interface::gene_matrix
TinyMatrix< real, SIZE, SIZE > gene_matrix
Definition: tiny_blitz_interface.hh:45
tiny_blitz_interface::stl_matrix
std::vector< stl_vector > stl_matrix
Definition: tiny_blitz_interface.hh:42
E1::A
@ A
tiny_blitz_interface::vector_to_stl
static void vector_to_stl(gene_vector &B, stl_vector &B_stl)
Definition: tiny_blitz_interface.hh:64
tiny_blitz_interface::real_type
real real_type
Definition: tiny_blitz_interface.hh:39
product
void product(const MatrixType &m)
Definition: product.h:20
tiny_blitz_interface::matrix_from_stl
static void matrix_from_stl(gene_matrix &A, stl_matrix &A_stl)
Definition: tiny_blitz_interface.hh:53
tiny_blitz_interface::vector_from_stl
static void vector_from_stl(gene_vector &B, stl_vector &B_stl)
Definition: tiny_blitz_interface.hh:59
N
#define N
Definition: igam.h:9
tiny_blitz_interface::matrix_matrix_product
static void matrix_matrix_product(const gene_matrix &A, const gene_matrix &B, gene_matrix &X, int N)
Definition: tiny_blitz_interface.hh:91
real
Definition: main.h:100
i
int i
Definition: BiCGSTAB_step_by_step.cpp:9
tiny_blitz_interface::copy_vector
static void copy_vector(const gene_vector &source, gene_vector &cible, int N)
Definition: tiny_blitz_interface.hh:85


gtsam
Author(s):
autogenerated on Fri Nov 1 2024 03:42:30