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

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

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