Main Page | User's Guide | Namespace List | Class Hierarchy | Class List | Directories | File List | Namespace Members | Class Members

Matrix_SymPacked.hxx

00001 // Copyright (C) 2001-2004 Vivien Mallet
00002 //
00003 // This file is part of Seldon library.
00004 // Seldon library provides matrices and vectors structures for
00005 // linear algebra.
00006 // 
00007 // Seldon is free software; you can redistribute it and/or modify
00008 // it under the terms of the GNU General Public License as published by
00009 // the Free Software Foundation; either version 2 of the License, or
00010 // (at your option) any later version.
00011 // 
00012 // Seldon is distributed in the hope that it will be useful,
00013 // but WITHOUT ANY WARRANTY; without even the implied warranty of
00014 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015 // GNU General Public License (file "license") for more details.
00016 //
00017 // For more information, please see the Seldon home page:
00018 //     http://spacetown.free.fr/lib/seldon/
00019 
00020 // To be included by Seldon.hxx
00021 
00022 #ifndef SELDON_FILE_MATRIX_SYMPACKED_HXX
00023 
00024 #include "../Common/Common.hxx"
00025 #include "../Common/Properties.hxx"
00026 #include "../Common/Storage.hxx"
00027 #include "../Common/Errors.cxx"
00028 #include "../Common/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_SymPacked: public Spacetown, public Matrix_Base<T, Allocator>
00038   {
00039     // typedef declaration.
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 
00047     // Attributes.
00048   protected:
00049 
00050     // Methods.
00051   public:
00052     // Constructor.
00053     Matrix_SymPacked();
00054     Matrix_SymPacked(int i, int j = 0);
00055 
00056     // Destructor.
00057     ~Matrix_SymPacked();
00058     void Clear();
00059 
00060     // Basic methods.
00061     int GetDataSize() const;
00062 
00063     // Memory management.
00064     void Reallocate(int i, int j);
00065     void SetData(int i, int j, pointer data);
00066     void Nullify();
00067 
00068     // Element access and affectation.
00069     reference operator() (int i, int j);
00070     const_reference operator() (int i, int j) const;
00071     reference Val(int i, int j);
00072     const_reference Val(int i, int j) const;
00073     reference operator[] (int i);
00074     const_reference operator[] (int i) const;
00075     Matrix_SymPacked<T, Prop, Storage, Allocator>&
00076     operator= (const Matrix_SymPacked<T, Prop, Storage, Allocator>& A);
00077     void Copy(const Matrix_SymPacked<T, Prop, Storage, Allocator>& A);
00078 
00079     // Convenient functions.
00080     void Zero();
00081     void SetIdentity();
00082     void Fill();
00083     template <class T0>
00084     void Fill(const T0& x);
00085     template <class T0>
00086     Matrix_SymPacked<T, Prop, Storage, Allocator>& operator= (const T0& x);
00087     void FillRand();
00088     void Print() const;
00089     void Print(int a, int b, int m, int n) const;
00090     void Print(int l) const;
00091 
00092     // Norms.
00093     value_type GetNormInf() const;
00094 
00095     // Input/output functions.
00096     void Write(string FileName) const;
00097     void Write(ofstream& FileStream) const;
00098     void WriteText(string FileName) const;
00099     void WriteText(ofstream& FileStream) const;
00100     void Read(string FileName);
00101     void Read(ifstream& FileStream);
00102 
00103   };
00104 
00105 
00107   template <class T, class Prop, class Allocator>
00108   class Matrix<T, Prop, ColSymPacked, Allocator>:
00109     public Matrix_SymPacked<T, Prop, ColSymPacked, Allocator>
00110   {
00111   public:
00112     Matrix();
00113     Matrix(int i, int j = 0);
00114 
00115     template <class T0>
00116     Matrix<T, Prop, ColSymPacked, Allocator>& operator= (const T0& x);
00117   };
00118 
00119 
00121   template <class T, class Prop, class Allocator>
00122   class Matrix<T, Prop, RowSymPacked, Allocator>:
00123     public Matrix_SymPacked<T, Prop, RowSymPacked, Allocator>
00124   {
00125   public:
00126     Matrix();
00127     Matrix(int i, int j = 0);
00128 
00129     template <class T0>
00130     Matrix<T, Prop, RowSymPacked, Allocator>& operator= (const T0& x);
00131   };
00132 
00133 
00134 } // namespace Seldon.
00135 
00136 #define SELDON_FILE_MATRIX_SYMPACKED_HXX
00137 #endif

Generated on Sun Jan 16 23:37:58 2005 for Multivac by  doxygen 1.4.0