matrix/SubMatrix_Base.hxx

00001 // Copyright (C) 2009 Vivien Mallet
00002 //
00003 // This file is part of the linear-algebra library Seldon,
00004 // http://seldon.sourceforge.net/.
00005 //
00006 // Seldon is free software; you can redistribute it and/or modify it under the
00007 // terms of the GNU Lesser General Public License as published by the Free
00008 // Software Foundation; either version 2.1 of the License, or (at your option)
00009 // any later version.
00010 //
00011 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY
00012 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
00013 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for
00014 // more details.
00015 //
00016 // You should have received a copy of the GNU Lesser General Public License
00017 // along with Seldon. If not, see http://www.gnu.org/licenses/.
00018 
00019 
00020 #ifndef SELDON_FILE_SUBMATRIX_BASE_HXX
00021 
00022 
00023 namespace Seldon
00024 {
00025 
00026 
00028   template <class T, class Prop, class M, class Allocator>
00029   class SubMatrix_Base: public Matrix_Base<T, Allocator>
00030   {
00031     // typedef declaration.
00032   public:
00033     typedef typename M::value_type value_type;
00034     typedef typename M::pointer pointer;
00035     typedef typename M::const_pointer const_pointer;
00036     typedef typename M::reference reference;
00037     typedef typename M::const_reference const_reference;
00038     typedef typename M::entry_type entry_type;
00039     typedef typename M::access_type access_type;
00040     typedef typename M::const_access_type const_access_type;
00041 
00042     // Attributes.
00043   protected:
00045     M* matrix_;
00047     Vector<int> row_list_;
00049     Vector<int> column_list_;
00050 
00051     // Methods.
00052   public:
00053     // Constructor.
00054     SubMatrix_Base(M& A, Vector<int>& row_list, Vector<int>& column_list);
00055 
00056     // Destructor.
00057     ~SubMatrix_Base();
00058 
00059     // Element access and affectation.
00060     access_type operator() (int i, int j);
00061 #ifndef SWIG
00062     const_access_type operator() (int i, int j) const;
00063 #endif
00064     entry_type& Val(int i, int j);
00065 #ifndef SWIG
00066     const entry_type& Val(int i, int j) const;
00067 #endif
00068 
00069     // Basic methods.
00070     int GetM() const;
00071     int GetN() const;
00072     int GetM(const SeldonTranspose& status) const;
00073     int GetN(const SeldonTranspose& status) const;
00074     void Print() const;
00075   };
00076 
00077 
00078 } // namespace Seldon.
00079 
00080 
00081 #define SELDON_FILE_SUBMATRIX_BASE_HXX
00082 #endif