Main Page   Class Hierarchy   Compound List   File List   Compound Members   File Members  

matrixSD.h

Go to the documentation of this file.
00001 #ifndef MATRIXSD_H
00002 #define MATRIXSD_H
00003 /*------------------------------------------------------------------------------
00004  * matrixSD.h   A simple, easy to use and efficient Matrix library.
00005  *              Definition and partial implementation of class MatrixSD.
00006  *              
00007  *              Copyright 1997,1998,1999,2000 Roland Krause
00008  * -----------------------------------------------------------------------------
00009  * RCS/CVS history of changes
00010  *  
00011  * $Log: matrixSD.h,v $
00012  * Revision 1.3  2000/11/09 18:41:31  rokrau
00013  * The first commit to the sourceforge repostory. Update of all
00014  * intermediate changes makes this the official repository from now on.
00015  *
00016  * Revision 1.3  2000/11/09 17:51:54  rokrau
00017  * Removed one of the redundant multiplication methods.
00018  *
00019  * Revision 1.2  2000/10/27 17:08:09  rokrau
00020  * some fixes for integer matrices
00021  *
00022  * Revision 1.1  2000/10/24 06:03:04  rokrau
00023  * Split header files, made Ref constructor private w/ some drastic consequences for
00024  * Ref operators. A lot of minor changes.
00025  *
00026  * -----------------------------------------------------------------------------
00027  * $Date: 2000/11/09 18:41:31 $
00028  * $Revision: 1.3 $
00029  * $Author: rokrau $
00030  * $State: Exp $
00031  * -----------------------------------------------------------------------------
00032  */
00033 // standard includes
00034 // project includes
00035 #include    "matrix.h"
00043 #define MAT_CS(M,NR,I,J) (M[((J)*(2*(NR)-(J)+1)/2)+(I)-(J)])
00044 #define REF_CS(A,I,J) MAT_CS(((A).D)->m,((A).D)->nrow,I,J)
00045 #define THIS_CS(I,J) REF_CS(*this,I,J)
00046 
00049 #ifdef USE_NAMESPACE_LINAL
00050 namespace LinAl {
00051 #endif
00052 
00063 class MatrixSD:public MatrixC<double>
00064 {
00065 public:
00067 
00068 
00069     explicit MatrixSD () : MatrixC<double>() {}
00071     explicit MatrixSD (const int nr, const double value=0.0) :
00072         MatrixC<double>(nr*(nr+1)/2,1,value) {D->nrow=D->ncol=nr;}
00074     MatrixSD (const MatrixSD& B) : MatrixC<double>(B) {} ;
00076     ~MatrixSD () {} ;
00078     MatrixSD& operator = (const double value)
00079         {this->MatrixC<double>::operator=(value); return *this;}
00081 
00082 
00083 
00084     void resize (const int nr, const double value=0.0) ;
00086     virtual int nr() const {return D->nrow;}
00087     virtual int nr(const int i) const {return D->nrow-i;}
00089     virtual int nc() const {return D->nrow;}
00090     virtual int nc(const int i) const {return i+1;}
00092     virtual Ref<double> operator () (const int i, const int j=0) {return MatrixC<double>::operator()(i,j);}
00094     virtual double operator () (const int i, const int j=0) const {assert(i>=j);return THIS_CS(i,j);}
00096 
00097 
00098     virtual void stream(ostream& s);
00100 
00105 
00106     MatrixSD transpose() const ;
00107     /*
00108      * Multiplication of two symmetric matrices destroys the symmetry. Therefore
00109      * it doesnt quite make sense. Instead multiplication of a symmetric
00110      * matrix with a full matrix is implemented as a member function of
00111      * the full matrix class.
00112      */
00114     void multiply(const MatrixSD& A, const MatrixSD& B,
00115                             const char TRANSA='N', const char TRANSB='N')
00116     {
00117         cout <<
00118         "Multiplication of two symmetric matrices destroys the symmetry. \n" <<
00119         "Therefore it doesnt quite make sense. Instead multiplication of \n" <<
00120         "a symmetric matrix with a full matrix is implemented as a member\n" <<
00121         "function of the full matrix class.\n" ;
00122     }
00124     void multiply(const double value);
00126     void multiply(const VectorD& x, VectorD& y, const double ALPHA=1.0, const double BETA=0.0) const;
00128     void CHdecompose() ;
00130     void CHsubstitute(MatrixC<double>& B) ;
00132     void CHsolve(MatrixC<double>& B) ;
00134     void CHinvert() ;
00136 protected:
00138     virtual double* ref(const int i, const int j) const {assert(i>=j);return &THIS_CS(i,j);}
00140     virtual double read(const int i, const int j) const {assert(i>=j);return THIS_CS(i,j);}
00142     virtual void write(const int i, const int j, const double v) {assert(i>=j);D=D->get_own_copy();THIS_CS(i,j)=v;}
00144     virtual void add(const int i, const int j, const double v) {assert(i>=j); D=D->get_own_copy();THIS_CS(i,j)+=v;}
00146     virtual void sub(const int i, const int j, const double v) {assert(i>=j); D=D->get_own_copy();THIS_CS(i,j)-=v;}
00148     virtual void mul(const int i, const int j, const double v) {assert(i>=j); D=D->get_own_copy();THIS_CS(i,j)*=v;}
00150     virtual void div(const int i, const int j, const double v) {assert(i>=j); D=D->get_own_copy();THIS_CS(i,j)/=v;}
00151 };
00152 #ifdef USE_NAMESPACE_LINAL
00153 } // namespace LinAl
00154 #endif
00155 #endif // #ifndef MATRIXSD_H

Generated at Wed Nov 22 08:38:28 2000 for LinAl - a simple and efficient Matrix library - by doxygen1.2.1 written by Dimitri van Heesch, © 1997-2000