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

Matrix_SymSparse.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_SYMSPARSE_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 
00043   template <class T, class Prop, class Storage,
00044             class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00045   class Matrix_SymSparse: public Spacetown, public Matrix_Base<T, Allocator>
00046   {
00047     // typedef declaration.
00048   public:
00049     typedef typename Allocator::value_type value_type;
00050     typedef typename Allocator::pointer pointer;
00051     typedef typename Allocator::const_pointer const_pointer;
00052     typedef typename Allocator::reference reference;
00053     typedef typename Allocator::const_reference const_reference;
00054 
00055     // Attributes.
00056   protected:
00057     // Number of non-zero (stored) elements.
00058     int nz_;
00059     // Index (in data_) of first element stored for each row or column.
00060     int* ptr_;
00061     // Column or row index (in the matrix) each element.
00062     int* ind_;
00063 
00064     // Methods.
00065   public:
00066     // Constructors.
00067     Matrix_SymSparse();
00068     Matrix_SymSparse(int i, int j);
00069     Matrix_SymSparse(int i, int j, int nz);
00070     template <class Storage0, class Allocator0,
00071               class Storage1, class Allocator1,
00072               class Storage2, class Allocator2>
00073     Matrix_SymSparse(int i, int j, Vector<T, Storage0, Allocator0>& values,
00074                      Vector<int, Storage1, Allocator1>& ptr,
00075                      Vector<int, Storage2, Allocator2>& ind);
00076     
00077     // Destructor.
00078     ~Matrix_SymSparse();
00079     void Clear();
00080 
00081     // Memory management.
00082     template <class Storage0, class Allocator0,
00083               class Storage1, class Allocator1,
00084               class Storage2, class Allocator2>
00085     void SetData(int i, int j,
00086                  Vector<T, Storage0, Allocator0>& values,
00087                  Vector<int, Storage1, Allocator1>& ptr,
00088                  Vector<int, Storage2, Allocator2>& ind);
00089     void SetData(int i, int j, int nz, pointer values, int* ptr, int* ind);
00090 
00091     // Basic methods.
00092     int GetNonZeros() const;
00093     int GetDataSize() const;
00094     int* GetPtr() const;
00095     int* GetInd() const;
00096     int GetPtrSize() const;
00097     int GetIndSize() const;
00098 
00099     // Element acess and affectation.
00100     value_type operator() (int i, int j) const;
00101     
00102     // Convenient functions.
00103     void Print() const;
00104     void SetDiags();
00105   };
00106 
00107 
00109   template <class T, class Prop, class Allocator>
00110   class Matrix<T, Prop, ColSymSparse, Allocator>:
00111     public Matrix_SymSparse<T, Prop, ColSymSparse, Allocator>
00112   {
00113   public:
00114     Matrix()  throw();
00115     Matrix(int i, int j);
00116     Matrix(int i, int j, int nz);
00117     template <class Storage0, class Allocator0,
00118               class Storage1, class Allocator1,
00119               class Storage2, class Allocator2>
00120     Matrix(int i, int j,
00121            Vector<T, Storage0, Allocator0>& values,
00122            Vector<int, Storage1, Allocator1>& ptr,
00123            Vector<int, Storage2, Allocator2>& ind);
00124   };
00125 
00126 
00128   template <class T, class Prop, class Allocator>
00129   class Matrix<T, Prop, RowSymSparse, Allocator>:
00130     public Matrix_SymSparse<T, Prop, RowSymSparse, Allocator>
00131   {
00132   public:
00133     Matrix()  throw();
00134     Matrix(int i, int j);
00135     Matrix(int i, int j, int nz);
00136     template <class Storage0, class Allocator0,
00137               class Storage1, class Allocator1,
00138               class Storage2, class Allocator2>
00139     Matrix(int i, int j,
00140            Vector<T, Storage0, Allocator0>& values,
00141            Vector<int, Storage1, Allocator1>& ptr,
00142            Vector<int, Storage2, Allocator2>& ind);
00143   };
00144 
00145 
00146 } // namespace Seldon.
00147 
00148 #define SELDON_FILE_MATRIX_SYMSPARSE_HXX
00149 #endif

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