Matrix_Base.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_CXX
21 
22 #include "Matrix_Base.hxx"
23 
24 namespace Seldon
25 {
26 
27 #ifdef SELDON_WITH_VIRTUAL
28  template <class T>
30  void VirtualMatrix<T>::Reallocate(int m, int n)
31  {
32  // this method should be overloaded
33  // if not overloaded, an exception is raised:
34  throw Undefined("Reallocate", "Not implemented");
35  }
36 
37 
39  template <class T>
40  void VirtualMatrix<T>::Zero()
41  {
42  // this method should be overloaded
43  // if not overloaded, an exception is raised:
44  throw Undefined("Zero", "Not implemented");
45  }
46 
47 
49  template <class T>
50  void VirtualMatrix<T>::SetEntry(int i, int j, const T& x)
51  {
52  // this method should be overloaded in sparse matrices
53  // if not overloaded, an exception is raised:
54  throw Undefined("SetEntry", "Not implemented");
55  }
56 
57 
59  template <class T>
60  void VirtualMatrix<T>::AddInteraction(int i, int j, const T& x)
61  {
62  // this method should be overloaded in sparse matrices
63  // if not overloaded, an exception is raised:
64  throw Undefined("AddInteraction", "Not implemented");
65  }
66 
67 
69  template <class T>
70  void VirtualMatrix<T>::AddInteractionRow(int, int, const Vector<int>&,
71  const Vector<T>& val, bool sorted)
72  {
73  // this method should be overloaded in sparse matrices
74  // if not overloaded, an exception is raised:
75  throw Undefined("AddInteractionRow", "Not implemented");
76  }
77 
78 
80  template <class T>
81  void VirtualMatrix<T>::AddInteractionColumn(int, int, const Vector<int>&,
82  const Vector<T>& val, bool sorted)
83  {
84  // this method should be overloaded in sparse matrices
85  // if not overloaded, an exception is raised:
86  throw Undefined("AddInteractionColumn", "Not implemented");
87  }
88 
89 
91 
99  template <class T>
100  void VirtualMatrix<T>::AddDistantInteraction(int i, int jglob, int proc,
101  const T& val)
102  {
103  // this method should be overloaded in distributed sparse matrices
104  // if not overloaded, an exception is raised:
105  throw Undefined("AddDistantInteraction", "Not implemented");
106  }
107 
108 
110 
118  template <class T>
119  void VirtualMatrix<T>::AddRowDistantInteraction(int iglob, int j, int proc,
120  const T& val)
121  {
122  // this method should be overloaded in distributed sparse matrices
123  // if not overloaded, an exception is raised:
124  throw Undefined("AddRowDistantInteraction", "Not implemented");
125  }
126 
127 
129  template <class T>
130  size_t VirtualMatrix<T>::GetMemorySize() const
131  {
132  // this method should be overloaded
133  // if not overloaded, an exception is raised:
134  throw Undefined("GetMemorySize", "Not implemented");
135  }
136 
137 
139  template <class T>
140  void VirtualMatrix<T>::Clear()
141  {
142  // this method should be overloaded
143  // if not overloaded, an exception is raised:
144  throw Undefined("Clear", "Not implemented");
145  }
146 
147 
149  template <class T>
150  inline void VirtualMatrix<T>::ClearRow(int i)
151  {
152  // this method should be overloaded in sparse matrices
153  // if not overloaded, an exception is raised:
154  throw Undefined("ClearRow", "Not implemented");
155  }
156 
157 
159  template<class T> void VirtualMatrix<T>
160  ::ApplySor(const SeldonTranspose&, Vector<Treal>& x, const Vector<Treal>& r,
161  const typename ClassComplexType<T>::Treal& omega,
162  int nb_iter, int stage_ssor) const
163  {
164  throw Undefined("ApplySOR", "Not implemented");
165  }
166 
167 
169  template<class T> void VirtualMatrix<T>
170  ::ApplySor(const SeldonTranspose&, Vector<Tcplx>& x, const Vector<Tcplx>& r,
171  const typename ClassComplexType<T>::Treal& omega,
172  int nb_iter, int stage_ssor) const
173  {
174  throw Undefined("ApplySOR with transpose", "Not implemented");
175  }
176 
177 
179  template<class T> void VirtualMatrix<T>
180  ::MltAddVector(const Treal& alpha, const Vector<Treal>& x,
181  const Treal& beta, Vector<Treal>& y) const
182  {
183  throw Undefined("MltAddVector", "Not implemented");
184  }
185 
186 
188  template<class T> void VirtualMatrix<T>
189  ::MltAddVector(const Tcplx& alpha, const Vector<Tcplx>& x,
190  const Tcplx& beta, Vector<Tcplx>& y) const
191  {
192  throw Undefined("MltAddVector", "Not implemented");
193  }
194 
195 
197  template<class T> void VirtualMatrix<T>
198  ::MltAddVector(const Treal& alpha, const SeldonTranspose&,
199  const Vector<Treal>& x,
200  const Treal& beta, Vector<Treal>& y) const
201  {
202  throw Undefined("MltAddVector", "Not implemented");
203  }
204 
205 
207  template<class T> void VirtualMatrix<T>
208  ::MltAddVector(const Tcplx& alpha, const SeldonTranspose&,
209  const Vector<Tcplx>& x,
210  const Tcplx& beta, Vector<Tcplx>& y) const
211  {
212  throw Undefined("MltAddVector", "Not implemented");
213  }
214 
215 
217  template<class T> void VirtualMatrix<T>
218  ::MltVector(const Vector<Treal>& x, Vector<Treal>& y) const
219  {
220  throw Undefined("MltVector", "Not implemented");
221  }
222 
223 
225  template<class T> void VirtualMatrix<T>
226  ::MltVector(const Vector<Tcplx>& x, Vector<Tcplx>& y) const
227  {
228  throw Undefined("MltVector", "Not implemented");
229  }
230 
231 
233  template<class T> void VirtualMatrix<T>
234  ::MltVector(const SeldonTranspose&,
235  const Vector<Treal>& x, Vector<Treal>& y) const
236  {
237  throw Undefined("MltVector with transpose", "Not implemented");
238  }
239 
240 
242  template<class T> void VirtualMatrix<T>
243  ::MltVector(const SeldonTranspose&,
244  const Vector<Tcplx>& x, Vector<Tcplx>& y) const
245  {
246  throw Undefined("MltVector with transpose", "Not implemented");
247  }
248 
249 
251  template<class T> bool VirtualMatrix<T>::IsSymmetric() const
252  {
253  return false;
254  }
255 
256 
258  template<class T> bool VirtualMatrix<T>::IsComplex() const
259  {
260  return IsComplexNumber(T());
261  }
262 #endif
263 
264 
265  // operator<< overloaded for matrices.
271  template <class T, class Prop, class Storage, class Allocator>
272  ostream& operator << (ostream& out,
274  {
275 
276  for (int i = 0; i < A.GetM(); i++)
277  {
278  for (int j = 0; j < A.GetN(); j++)
279  out << A(i, j) << '\t';
280  out << endl;
281  }
282 
283  return out;
284 
285  }
286 
287 } // namespace Seldon.
288 
289 #define SELDON_FILE_MATRIX_BASE_CXX
290 #endif
Seldon::Matrix
Definition: SeldonHeader.hxx:226
Seldon::IsComplexNumber
bool IsComplexNumber(const T &number)
Returns true for a complex number.
Definition: CommonInline.cxx:293
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::operator<<
ostream & operator<<(ostream &out, const Array< T, N, Allocator > &A)
operator<< overloaded for a 3D array.
Definition: Array.cxx:1617