00001 
00002 
00003 
00004 
00005 
00006 
00007 
00008 
00009 
00010 
00011 
00012 
00013 
00014 
00015 
00016 
00017 
00018 
00019 
00020 
00021 
00022 #ifndef SELDON_FILE_MATRIX_POINTERS_HXX
00023 
00024 #include "../share/Common.hxx"
00025 #include "../share/Properties.hxx"
00026 #include "../share/Storage.hxx"
00027 #include "../share/Errors.hxx"
00028 #include "../share/Allocator.hxx"
00029 
00030 namespace Seldon
00031 {
00032 
00033 
00035   template <class T, class Prop, class Storage,
00036             class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00037   class Matrix_Pointers: public Matrix_Base<T, Allocator>
00038   {
00039     
00040   public:
00041     typedef typename Allocator::value_type value_type;
00042     typedef typename Allocator::pointer pointer;
00043     typedef typename Allocator::const_pointer const_pointer;
00044     typedef typename Allocator::reference reference;
00045     typedef typename Allocator::const_reference const_reference;
00046     typedef typename Allocator::value_type entry_type;
00047     typedef typename Allocator::reference access_type;
00048     typedef typename Allocator::const_reference const_access_type;
00049 
00050     
00051   protected:
00052     pointer* me_;
00053 
00054     
00055   public:
00056     
00057     Matrix_Pointers();
00058     Matrix_Pointers(int i, int j);
00059     Matrix_Pointers(const Matrix_Pointers<T, Prop, Storage, Allocator>& A);
00060 
00061     
00062     ~Matrix_Pointers();
00063     void Clear();
00064 
00065     
00066     int GetDataSize() const;
00067 
00068     
00069     void Reallocate(int i, int j);
00070     void SetData(int i, int j, pointer data);
00071     void Nullify();
00072     void Resize(int i, int j);
00073 
00074     
00075     reference operator() (int i, int j);
00076 #ifndef SWIG
00077     const_reference operator() (int i, int j) const;
00078 #endif
00079     reference Val(int i, int j);
00080 #ifndef SWIG
00081     const_reference Val(int i, int j) const;
00082     reference operator[] (int i);
00083     const_reference operator[] (int i) const;
00084     Matrix_Pointers<T, Prop, Storage, Allocator>&
00085     operator= (const Matrix_Pointers<T, Prop, Storage, Allocator>& A);
00086 #endif
00087     void Copy(const Matrix_Pointers<T, Prop, Storage, Allocator>& A);
00088 
00089     
00090     int GetLD() const;
00091     void Zero();
00092     void SetIdentity();
00093     void Fill();
00094     template <class T0>
00095     void Fill(const T0& x);
00096 #ifndef SWIG
00097     template <class T0>
00098     Matrix_Pointers<T, Prop, Storage, Allocator>& operator= (const T0& x);
00099 #endif
00100     void FillRand();
00101     void Print() const;
00102     void Print(int a, int b, int m, int n) const;
00103     void Print(int l) const;
00104 
00105     
00106     void Write(string FileName, bool with_size = true) const;
00107     void Write(ostream& FileStream, bool with_size = true) const;
00108     void WriteText(string FileName) const;
00109     void WriteText(ostream& FileStream) const;
00110     void Read(string FileName, bool with_size = true);
00111     void Read(istream& FileStream, bool with_size = true);
00112     void ReadText(string FileName);
00113     void ReadText(istream& FileStream);
00114   };
00115 
00116 
00118   template <class T, class Prop, class Allocator>
00119   class Matrix<T, Prop, ColMajor, Allocator>:
00120     public Matrix_Pointers<T, Prop, ColMajor, Allocator>
00121   {
00122     
00123   public:
00124     typedef typename Allocator::value_type value_type;
00125     typedef Prop property;
00126     typedef ColMajor storage;
00127     typedef Allocator allocator;
00128 
00129   public:
00130     Matrix()  throw();
00131     Matrix(int i, int j);
00132     Matrix(const Matrix<T, Prop, ColMajor, Allocator>& A);
00133 
00134 #ifndef SWIG
00135     template <class T0>
00136     Matrix<T, Prop, ColMajor, Allocator>& operator= (const T0& x);
00137     Matrix<T, Prop, ColMajor, Allocator>& operator=(const Matrix<T, Prop,
00138                                                     ColMajor, Allocator>& A);
00139 #endif
00140     template<class T0>
00141     Matrix<T, Prop, ColMajor, Allocator>& operator*= (const T0& x);
00142   };
00143 
00144 
00146   template <class T, class Prop, class Allocator>
00147   class Matrix<T, Prop, RowMajor, Allocator>:
00148     public Matrix_Pointers<T, Prop, RowMajor, Allocator>
00149   {
00150     
00151   public:
00152     typedef typename Allocator::value_type value_type;
00153     typedef Prop property;
00154     typedef RowMajor storage;
00155     typedef Allocator allocator;
00156 
00157   public:
00158     Matrix()  throw();
00159     Matrix(int i, int j);
00160     Matrix(const Matrix<T, Prop, RowMajor, Allocator>& A);
00161 
00162 #ifndef SWIG
00163 
00164     template <class T0>
00165     Matrix<T, Prop, RowMajor, Allocator>& operator= (const T0& x);
00166     Matrix<T, Prop, RowMajor, Allocator>& operator=(const Matrix<T, Prop,
00167                                                     RowMajor, Allocator>& A);
00168 #endif
00169     template<class T0>
00170     Matrix<T, Prop, RowMajor, Allocator>& operator*= (const T0& x);
00171   };
00172 
00173 
00174 } 
00175 
00176 #define SELDON_FILE_MATRIX_POINTERS_HXX
00177 #endif