Warning: this documentation for the development version is under construction.
00001 // Copyright (C) 2001-2009 Vivien Mallet 00002 // Copyright (C) 2003-2009 Marc Duruflé 00003 // 00004 // This file is part of the linear-algebra library Seldon, 00005 // http://seldon.sourceforge.net/. 00006 // 00007 // Seldon is free software; you can redistribute it and/or modify it under the 00008 // terms of the GNU Lesser General Public License as published by the Free 00009 // Software Foundation; either version 2.1 of the License, or (at your option) 00010 // any later version. 00011 // 00012 // Seldon is distributed in the hope that it will be useful, but WITHOUT ANY 00013 // WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS 00014 // FOR A PARTICULAR PURPOSE. See the GNU Lesser General Public License for 00015 // more details. 00016 // 00017 // You should have received a copy of the GNU Lesser General Public License 00018 // along with Seldon. If not, see http://www.gnu.org/licenses/. 00019 00020 00021 // To be included by Seldon.hxx 00022 00023 #ifndef SELDON_FILE_MATRIX_TRIANGPACKED_HXX 00024 00025 #include "../share/Common.hxx" 00026 #include "../share/Properties.hxx" 00027 #include "../share/Storage.hxx" 00028 #include "../share/Errors.hxx" 00029 #include "../share/Allocator.hxx" 00030 00031 namespace Seldon 00032 { 00033 00034 00036 template <class T, class Prop, class Storage, 00037 class Allocator = SELDON_DEFAULT_ALLOCATOR<T> > 00038 class Matrix_TriangPacked: public Matrix_Base<T, Allocator> 00039 { 00040 // typedef declaration. 00041 public: 00042 typedef typename Allocator::value_type value_type; 00043 typedef typename Allocator::pointer pointer; 00044 typedef typename Allocator::const_pointer const_pointer; 00045 typedef typename Allocator::reference reference; 00046 typedef typename Allocator::const_reference const_reference; 00047 typedef typename Allocator::value_type entry_type; 00048 typedef typename Allocator::reference access_type; 00049 typedef typename Allocator::const_reference const_access_type; 00050 00051 // Attributes. 00052 protected: 00053 00054 // Methods. 00055 public: 00056 // Constructor. 00057 Matrix_TriangPacked(); 00058 Matrix_TriangPacked(int i, int j = 0); 00059 Matrix_TriangPacked(const Matrix_TriangPacked<T, Prop, Storage, 00060 Allocator>& A); 00061 00062 // Destructor. 00063 ~Matrix_TriangPacked(); 00064 void Clear(); 00065 00066 // Basic methods. 00067 int GetDataSize() const; 00068 00069 // Memory management. 00070 void Reallocate(int i, int j); 00071 void SetData(int i, int j, pointer data); 00072 void Nullify(); 00073 00074 // Element access and affectation. 00075 value_type operator() (int i, int j) const; 00076 reference Val(int i, int j); 00077 const_reference Val(int i, int j) const; 00078 reference Get(int i, int j); 00079 const_reference Get(int i, int j) const; 00080 reference operator[] (int i); 00081 const_reference operator[] (int i) const; 00082 Matrix_TriangPacked<T, Prop, Storage, Allocator>& 00083 operator= (const Matrix_TriangPacked<T, Prop, Storage, Allocator>& A); 00084 void Set(int i, int j, const T& x); 00085 void Copy(const Matrix_TriangPacked<T, Prop, Storage, Allocator>& A); 00086 00087 // Convenient functions. 00088 void Zero(); 00089 void SetIdentity(); 00090 void Fill(); 00091 template <class T0> 00092 void Fill(const T0& x); 00093 template <class T0> 00094 Matrix_TriangPacked<T, Prop, Storage, Allocator>& operator= (const T0& x); 00095 void FillRand(); 00096 void Print() const; 00097 void Print(int a, int b, int m, int n) const; 00098 void Print(int l) const; 00099 00100 // Input/output functions. 00101 void Write(string FileName) const; 00102 void Write(ostream& FileStream) const; 00103 void WriteText(string FileName) const; 00104 void WriteText(ostream& FileStream) const; 00105 void Read(string FileName); 00106 void Read(istream& FileStream); 00107 void ReadText(string FileName); 00108 void ReadText(istream& FileStream); 00109 00110 }; 00111 00112 00114 template <class T, class Prop, class Allocator> 00115 class Matrix<T, Prop, ColUpTriangPacked, Allocator>: 00116 public Matrix_TriangPacked<T, Prop, ColUpTriangPacked, Allocator> 00117 { 00118 // typedef declaration. 00119 public: 00120 typedef typename Allocator::value_type value_type; 00121 typedef Prop property; 00122 typedef ColUpTriangPacked storage; 00123 typedef Allocator allocator; 00124 00125 public: 00126 Matrix(); 00127 Matrix(int i, int j = 0); 00128 void Resize(int i, int j); 00129 00130 template <class T0> 00131 Matrix<T, Prop, ColUpTriangPacked, Allocator>& operator= (const T0& x); 00132 Matrix<T, Prop, ColUpTriangPacked, Allocator>& 00133 operator= (const Matrix<T, Prop, ColUpTriangPacked, Allocator>& A); 00134 template <class T0> 00135 Matrix<T, Prop, ColUpTriangPacked, Allocator>& operator*= (const T0& x); 00136 }; 00137 00138 00140 template <class T, class Prop, class Allocator> 00141 class Matrix<T, Prop, ColLoTriangPacked, Allocator>: 00142 public Matrix_TriangPacked<T, Prop, ColLoTriangPacked, Allocator> 00143 { 00144 // typedef declaration. 00145 public: 00146 typedef typename Allocator::value_type value_type; 00147 typedef Prop property; 00148 typedef ColLoTriangPacked storage; 00149 typedef Allocator allocator; 00150 00151 public: 00152 Matrix(); 00153 Matrix(int i, int j = 0); 00154 void Resize(int i, int j); 00155 00156 template <class T0> 00157 Matrix<T, Prop, ColLoTriangPacked, Allocator>& operator= (const T0& x); 00158 Matrix<T, Prop, ColLoTriangPacked, Allocator>& 00159 operator= (const Matrix<T, Prop, ColLoTriangPacked, Allocator>& A); 00160 template<class T0> 00161 Matrix<T, Prop, ColLoTriangPacked, Allocator>& operator*= (const T0& x); 00162 }; 00163 00164 00166 template <class T, class Prop, class Allocator> 00167 class Matrix<T, Prop, RowUpTriangPacked, Allocator>: 00168 public Matrix_TriangPacked<T, Prop, RowUpTriangPacked, Allocator> 00169 { 00170 // typedef declaration. 00171 public: 00172 typedef typename Allocator::value_type value_type; 00173 typedef Prop property; 00174 typedef RowUpTriangPacked storage; 00175 typedef Allocator allocator; 00176 00177 public: 00178 Matrix(); 00179 Matrix(int i, int j = 0); 00180 void Resize(int i, int j); 00181 00182 template <class T0> 00183 Matrix<T, Prop, RowUpTriangPacked, Allocator>& operator= (const T0& x); 00184 Matrix<T, Prop, RowUpTriangPacked, Allocator>& 00185 operator= (const Matrix<T, Prop, RowUpTriangPacked, Allocator>& A); 00186 template<class T0> 00187 Matrix<T, Prop, RowUpTriangPacked, Allocator>& operator*= (const T0& x); 00188 }; 00189 00190 00192 template <class T, class Prop, class Allocator> 00193 class Matrix<T, Prop, RowLoTriangPacked, Allocator>: 00194 public Matrix_TriangPacked<T, Prop, RowLoTriangPacked, Allocator> 00195 { 00196 // typedef declaration. 00197 public: 00198 typedef typename Allocator::value_type value_type; 00199 typedef Prop property; 00200 typedef RowLoTriangPacked storage; 00201 typedef Allocator allocator; 00202 00203 public: 00204 Matrix(); 00205 Matrix(int i, int j = 0); 00206 void Resize(int i, int j); 00207 00208 template <class T0> 00209 Matrix<T, Prop, RowLoTriangPacked, Allocator>& operator= (const T0& x); 00210 Matrix<T, Prop, RowLoTriangPacked, Allocator>& 00211 operator= (const Matrix<T, Prop, RowLoTriangPacked, Allocator>& A); 00212 template<class T0> 00213 Matrix<T, Prop, RowLoTriangPacked, Allocator>& operator*= (const T0& x); 00214 }; 00215 00216 00217 } // namespace Seldon. 00218 00219 #define SELDON_FILE_MATRIX_TRIANGPACKED_HXX 00220 #endif