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

Matrix_SymComplexSparse.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_SYMCOMPLEXSPARSE_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 
00047   template <class T, class Prop, class Storage,
00048             class Allocator = SELDON_DEFAULT_ALLOCATOR<T> >
00049   class Matrix_SymComplexSparse: public Spacetown,
00050                                  public Matrix_Base<T, Allocator>
00051   {
00052     // typedef declaration.
00053   public:
00054     typedef typename Allocator::value_type value_type;
00055     typedef typename Allocator::pointer pointer;
00056     typedef typename Allocator::const_pointer const_pointer;
00057     typedef typename Allocator::reference reference;
00058     typedef typename Allocator::const_reference const_reference;
00059 
00060     // Attributes.
00061   protected:
00062     // Number of non-zero (stored) elements.
00063     int real_nz_;
00064     int imag_nz_;
00065     // Index (in data_) of first element stored for each row or column.
00066     int* real_ptr_;
00067     int* imag_ptr_;
00068     // Column or row index (in the matrix) each element.
00069     int* real_ind_;
00070     int* imag_ind_;
00071 
00072     // Data.
00073     T* real_data_;
00074     T* imag_data_;
00075 
00076     // Methods.
00077   public:
00078     // Constructors.
00079     Matrix_SymComplexSparse();
00080     Matrix_SymComplexSparse(int i, int j);
00081     Matrix_SymComplexSparse(int i, int j, int real_nz, int imag_nz);
00082     template <class Storage0, class Allocator0,
00083               class Storage1, class Allocator1,
00084               class Storage2, class Allocator2>
00085     Matrix_SymComplexSparse(int i, int j,
00086                             Vector<T, Storage0, Allocator0>& real_values,
00087                             Vector<int, Storage1, Allocator1>& real_ptr,
00088                             Vector<int, Storage2, Allocator2>& real_ind,
00089                             Vector<T, Storage0, Allocator0>& imag_values,
00090                             Vector<int, Storage1, Allocator1>& imag_ptr,
00091                             Vector<int, Storage2, Allocator2>& imag_ind);
00092     
00093     // Destructor.
00094     ~Matrix_SymComplexSparse();
00095     void Clear();
00096 
00097     // Memory management.
00098     template <class Storage0, class Allocator0,
00099               class Storage1, class Allocator1,
00100               class Storage2, class Allocator2>
00101     void SetData(int i, int j,
00102                  Vector<T, Storage0, Allocator0>& real_values,
00103                  Vector<int, Storage1, Allocator1>& real_ptr,
00104                  Vector<int, Storage2, Allocator2>& real_ind,
00105                  Vector<T, Storage0, Allocator0>& imag_values,
00106                  Vector<int, Storage1, Allocator1>& imag_ptr,
00107                  Vector<int, Storage2, Allocator2>& imag_ind);
00108     void SetData(int i, int j,
00109                  int real_nz, pointer real_values, int* real_ptr,
00110                  int* real_ind,
00111                  int imag_nz, pointer imag_values, int* imag_ptr,
00112                  int* imag_ind);
00113 
00114     // Basic methods.
00115     int GetNonZeros() const;
00116     int GetDataSize() const;
00117     int* GetRealPtr() const;
00118     int* GetImagPtr() const;
00119     int* GetRealInd() const;
00120     int* GetImagInd() const;
00121     int GetRealPtrSize() const;
00122     int GetImagPtrSize() const;
00123     int GetRealIndSize() const;
00124     int GetImagIndSize() const;
00125     T* GetRealData() const;
00126     T* GetImagData() const;
00127 
00128     // Element acess and affectation.
00129     complex<value_type> operator() (int i, int j) const;
00130     
00131     // Convenient functions.
00132     void Print() const;
00133   };
00134 
00135 
00137   template <class T, class Prop, class Allocator>
00138   class Matrix<T, Prop, ColSymComplexSparse, Allocator>:
00139     public Matrix_SymComplexSparse<T, Prop, ColSymComplexSparse, Allocator>
00140   {
00141   public:
00142     Matrix()  throw();
00143     Matrix(int i, int j);
00144     Matrix(int i, int j, int real_nz, int imag_nz);
00145     template <class Storage0, class Allocator0,
00146               class Storage1, class Allocator1,
00147               class Storage2, class Allocator2>
00148     Matrix(int i, int j,
00149            Vector<T, Storage0, Allocator0>& real_values,
00150            Vector<int, Storage1, Allocator1>& real_ptr,
00151            Vector<int, Storage2, Allocator2>& real_ind,
00152            Vector<T, Storage0, Allocator0>& imag_values,
00153            Vector<int, Storage1, Allocator1>& imag_ptr,
00154            Vector<int, Storage2, Allocator2>& imag_ind);
00155   };
00156 
00157 
00159   template <class T, class Prop, class Allocator>
00160   class Matrix<T, Prop, RowSymComplexSparse, Allocator>:
00161     public Matrix_SymComplexSparse<T, Prop, RowSymComplexSparse, Allocator>
00162   {
00163   public:
00164     Matrix()  throw();
00165     Matrix(int i, int j);
00166     Matrix(int i, int j, int real_nz, int imag_nz);
00167     template <class Storage0, class Allocator0,
00168               class Storage1, class Allocator1,
00169               class Storage2, class Allocator2>
00170     Matrix(int i, int j,
00171            Vector<T, Storage0, Allocator0>& values,
00172            Vector<int, Storage1, Allocator1>& ptr,
00173            Vector<int, Storage2, Allocator2>& ind,
00174            Vector<T, Storage0, Allocator0>& imag_values,
00175            Vector<int, Storage1, Allocator1>& imag_ptr,
00176            Vector<int, Storage2, Allocator2>& imag_ind);
00177   };
00178 
00179 
00180 } // namespace Seldon.
00181 
00182 #define SELDON_FILE_MATRIX_SYMCOMPLEXSPARSE_HXX
00183 #endif

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