SubMatrix_Base.hxx
1 // Copyright (C) 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_SUBMATRIX_BASE_HXX
21 
22 
23 namespace Seldon
24 {
25 
26 
28  template <class T, class Prop, class M, class Allocator>
29  class SubMatrix_Base: public Matrix_Base<T, Allocator>
30  {
31  // typedef declaration.
32  public:
33  typedef typename M::value_type value_type;
34  typedef typename M::pointer pointer;
35  typedef typename M::const_pointer const_pointer;
36  typedef typename M::reference reference;
37  typedef typename M::const_reference const_reference;
38  typedef typename M::entry_type entry_type;
39  typedef typename M::access_type access_type;
40  typedef typename M::const_access_type const_access_type;
41  typedef M storage;
42 
43  // Attributes.
44  protected:
46  M* matrix_;
51 
52  // Methods.
53  public:
54  // Constructor.
55  SubMatrix_Base(M& A, Vector<int>& row_list, Vector<int>& column_list);
56 
57  // Destructor.
59 
60  // Element access and affectation.
61  access_type operator() (int i, int j);
62 #ifndef SWIG
63  const_access_type operator() (int i, int j) const;
64 #endif
65  entry_type& Val(int i, int j);
66 #ifndef SWIG
67  const entry_type& Val(int i, int j) const;
68 #endif
69 
70  // Basic methods.
71  int GetM() const;
72  int GetN() const;
73  int GetM(const SeldonTranspose& status) const;
74  int GetN(const SeldonTranspose& status) const;
75  void Print() const;
76 
77 #ifdef SELDON_WITH_VIRTUAL
78  void Reallocate(int, int) {}
79  size_t GetMemorySize() const { return 0; }
80 #endif
81 
82  };
83 
84 
85 } // namespace Seldon.
86 
87 
88 #define SELDON_FILE_SUBMATRIX_BASE_HXX
89 #endif
Seldon::SubMatrix_Base::~SubMatrix_Base
~SubMatrix_Base()
Destructor.
Definition: SubMatrix_BaseInline.cxx:57
Seldon::SeldonTranspose
Definition: MatrixFlag.hxx:32
Seldon::SubMatrix_Base::matrix_
M * matrix_
Pointer to the base matrix.
Definition: SubMatrix_Base.hxx:46
Seldon::Matrix_Base
Base class for all matrices.
Definition: Matrix_Base.hxx:143
Seldon::SubMatrix_Base::operator()
access_type operator()(int i, int j)
Access operator.
Definition: SubMatrix_BaseInline.cxx:76
Seldon::Vector< int >
Seldon::SubMatrix_Base::row_list_
Vector< int > row_list_
List of rows.
Definition: SubMatrix_Base.hxx:48
Seldon::SubMatrix_Base::GetM
int GetM() const
Returns the number of rows.
Definition: SubMatrix_BaseInline.cxx:137
Seldon::SubMatrix_Base
Sub-matrix base class.
Definition: SubMatrix_Base.hxx:29
Seldon::SubMatrix_Base::Print
void Print() const
Prints a matrix on screen.
Definition: SubMatrix_BaseInline.cxx:192
Seldon::SubMatrix_Base::column_list_
Vector< int > column_list_
List of columns.
Definition: SubMatrix_Base.hxx:50
Seldon::SubMatrix_Base::GetN
int GetN() const
Returns the number of columns.
Definition: SubMatrix_BaseInline.cxx:148
Seldon::SubMatrix_Base::SubMatrix_Base
SubMatrix_Base(M &A, Vector< int > &row_list, Vector< int > &column_list)
Main constructor.
Definition: SubMatrix_BaseInline.cxx:43
Seldon
Seldon namespace.
Definition: Array.cxx:24
Seldon::SubMatrix_Base::Val
entry_type & Val(int i, int j)
Access operator.
Definition: SubMatrix_BaseInline.cxx:106