Matrix_BaseInline.cxx
1 // Copyright (C) 2001-2009 Vivien Mallet
2 //
3 // This file is part of the linear-algebra library Seldon,
4 // http://seldon.sourceforge.net/.
5 //
6 // Seldon is free software; you can redistribute it and/or modify it under the
7 // terms of the GNU Lesser General Public License as published by the Free
8 // Software Foundation; either version 2.1 of the License, or (at your option)
9 // any later version.
10 //
11 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
12 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
13 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
14 // more details.
15 //
16 // You should have received a copy of the GNU Lesser General Public License
17 // along with Seldon. If not, see http://www.gnu.org/licenses/.
18 
19 
20 #ifndef SELDON_FILE_MATRIX_BASE_INLINE_CXX
21 
22 #include "Matrix_Base.hxx"
23 
24 namespace Seldon
25 {
26 
27  /*****************
28  * VirtualMatrix *
29  *****************/
30 
31 
33 
36  template <class T>
38  {
39  m_ = 0;
40  n_ = 0;
41  }
42 
43 
45 
49  template <class T>
50  inline VirtualMatrix<T>::VirtualMatrix(int i, int j)
51  {
52 #ifdef SELDON_CHECK_DIMENSIONS
53  if (i < 0 || j < 0)
54  throw WrongDim("VirtualMatrix::VirtualMatrix(int, int)",
55  "Unable to define a matrix with size "
56  + to_str(i) + " by " + to_str(j) + ".");
57 #endif
58 
59  m_ = i;
60  n_ = j;
61  }
62 
63 
65 
68  template <class T>
69  inline int VirtualMatrix<T>::GetM() const
70  {
71  return m_;
72  }
73 
74 
76 
79  template <class T>
80  inline int VirtualMatrix<T>::GetN() const
81  {
82  return n_;
83  }
84 
85 
87 
91  template <class T>
92  inline int VirtualMatrix<T>::GetM(const SeldonTranspose& status) const
93  {
94  if (status.NoTrans())
95  return m_;
96  else
97  return n_;
98  }
99 
100 
102 
106  template <class T>
107  inline int VirtualMatrix<T>::GetN(const SeldonTranspose& status) const
108  {
109  if (status.NoTrans())
110  return n_;
111  else
112  return m_;
113  }
114 
115 
117 
121  template <class T>
122  inline int VirtualMatrix<T>::GetM(const CBLAS_TRANSPOSE& status) const
123  {
124  if (status == CblasNoTrans)
125  return m_;
126  else
127  return n_;
128  }
129 
130 
132 
136  template <class T>
137  inline int VirtualMatrix<T>::GetN(const CBLAS_TRANSPOSE& status) const
138  {
139  if (status == CblasNoTrans)
140  return n_;
141  else
142  return m_;
143  }
144 
145 
147 
152  template <class T>
153  inline long VirtualMatrix<T>::GetSize() const
154  {
155  return long(m_) * long(n_);
156  }
157 
158 
159 #ifdef SELDON_WITH_VIRTUAL
160  template <class T>
163  {
164  }
165 #endif
166 
167 
168  /****************
169  * CONSTRUCTORS *
170  ****************/
171 
172 
174 
177  template <class T, class Allocator>
179  {
180  this->data_ = NULL;
181  }
182 
183 
185 
190  template <class T, class Allocator>
192  : VirtualMatrix<T>(i, j)
193  {
194  this->data_ = NULL;
195  }
196 
197 
199 
203  template <class T, class Allocator>
206  {
207  this->m_ = A.GetM();
208  this->n_ = A.GetN();
209  this->data_ = NULL;
210  }
211 
212 
213  /**************
214  * DESTRUCTOR *
215  **************/
216 
217 
219 
222  template <class T, class Allocator>
224  {
225 
226  }
227 
228 
229  /*******************
230  * BASIC FUNCTIONS *
231  *******************/
232 
233 
235 
239  template <class T, class Allocator>
240  inline typename Matrix_Base<T, Allocator>::pointer
242  {
243  return data_;
244  }
245 
246 
248 
252  template <class T, class Allocator>
253  inline typename Matrix_Base<T, Allocator>::const_pointer
255  {
256  return reinterpret_cast<typename Matrix_Base<T,
257  Allocator>::const_pointer>(data_);
258  }
259 
260 
262 
266  template <class T, class Allocator>
268  {
269  return reinterpret_cast<void*>(data_);
270  }
271 
272 
274 
279  template <class T, class Allocator>
281  {
282  return reinterpret_cast<const void*>(data_);
283  }
284 
285 } // namespace Seldon.
286 
287 #define SELDON_FILE_MATRIX_BASE_INLINE_CXX
288 #endif
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::Matrix_Base
Base class for all matrices.
Definition: Matrix_Base.hxx:143
Seldon::to_str
std::string to_str(const T &input)
Converts most types to string.
Definition: CommonInline.cxx:137
Seldon::VirtualMatrix::GetN
int GetN() const
Returns the number of columns.
Definition: Matrix_BaseInline.cxx:80
Seldon::VirtualMatrix::GetM
int GetM() const
Returns the number of rows.
Definition: Matrix_BaseInline.cxx:69
Seldon::VirtualMatrix::GetSize
long GetSize() const
Returns the number of elements in the matrix.
Definition: Matrix_BaseInline.cxx:153
Seldon::WrongDim
Definition: Errors.hxx:102
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::Matrix_Base::Matrix_Base
Matrix_Base()
Default constructor.
Definition: Matrix_BaseInline.cxx:178
Seldon::VirtualMatrix::VirtualMatrix
VirtualMatrix()
Default constructor.
Definition: Matrix_BaseInline.cxx:37
Seldon::VirtualMatrix
Abstract base class for all matrices.
Definition: Matrix_Base.hxx:42