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

bgmatrix.h

Go to the documentation of this file.
00001 //****************************************************
00002 //  April, 1993, University of Illinois
00003 // Copyright (C) 1993, 1994 Tianlin Wang
00004 /* Copyright (C) 1994-2003 Matvec Development Team. 
00005 
00006   This program is free software; you can redistribute it and/or
00007   modify it under the terms of the GNU Library General Public
00008   License as published by the Free Software Foundation; either
00009   version 2 of the License, or (at your option) any later version.
00010   
00011   This program is distributed in the hope that it will be useful,
00012   but WITHOUT ANY WARRANTY; without even the implied warranty of
00013   MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00014   Library General Public License for more details.
00015     
00016   You should have received a copy of the GNU Library General Public
00017   License along with this library; if not, write to the Free
00018   Software Foundation, Inc., 59 Temple Place - Suite 330, Boston,
00019   MA 02111-1307, USA 
00020 */
00021 
00022 #ifndef MATVEC_BG_MATRIX_H 
00023 #define MATVEC_BG_MATRIX_H
00024 
00025 #include <string>
00026 #include <fstream>
00027 #include "session.h"
00028 #include "matrix.h"
00029 #include "vector.h"
00030 #include "bg.h"
00031 
00032 namespace matvec {
00033 class BGMatrix : public Matrix<BG> {
00034   friend class Model;
00035 public:
00036    BGMatrix(void) : Matrix<BG>() {}
00037    BGMatrix(const doubleMatrix &a);
00038    explicit BGMatrix(const size_type m,const size_type n)     : Matrix<BG>(m,n){}
00039    BGMatrix(const size_type m,const size_type n,const BG** a) : Matrix<BG>(m,n,a){}
00040    BGMatrix(const BGMatrix& a) : Matrix<BG>(a) { }
00041    BGMatrix(const Matrix<BG>& a) : Matrix<BG>(a) { }
00042 
00043    BGMatrix&   operator = (const Matrix<BG> &a) { copy(a); return *this; }
00044    BGMatrix&   operator = (const Matrix<bool> &a);
00045 
00046    bool            psd(void) const;
00047    //void            svd(BGMatrix& u,Vector<BG>& s,BGMatrix& v);
00048    //int             rank(void);
00049    BGMatrix&   inv();
00050    BGMatrix    ginv0(void) const;
00051    BGMatrix    splines(const BGMatrix knots,const unsigned type=0) const;
00052    BGMatrix&   ginv1(unsigned *irank=0);
00053    BGMatrix   mat_log(double tol=0.0) const;  //Returns Matrix log
00054    BGMatrix   mat_exp(double tol=0.0) const;  //Returns Matrix exp
00055   void    mat_exp_der(Vector<BGMatrix> &der,double tol=0.0) const; // Returns  partial derivatives
00056    BGMatrix    covariance(const BGMatrix &B) const;
00057    Vector<BG>  variance(orientation orien = COLUMN) const;
00058    BGMatrix    lu_solve(const BGMatrix& rhs);
00059    Vector<BG>  lu_solve(const Vector<BG>& rhs);
00060    void            gs_solve(const BGMatrix& v,BGMatrix& solmat,const double relax=1.0,
00061                       const double stopval=0.001,const int mxiter=1000);
00062    void            gs_solve(const Vector<BG>& v,Vector<BG>& solvec,const double relax=1.0,
00063                       const double stopval=0.001,const int mxiter=1000);
00064 
00065    //Vector<BG>  eigen(const int job=1);
00066    BG          cond(void);
00067    BG          det(void) const;
00068    BG          norm(const int p) const;
00069    BG          norm(const std::string &s) const;
00070    BG          logdet(void);
00071    BG          quadratic(const Vector<BG> &a,const Vector<BG> &b) const;
00072    BGMatrix&   sqrtm(void);
00073    BGMatrix&   identity(const int m,const int n);
00074    BGMatrix&   identity(const int m) {return identity(m,m);}
00075    BGMatrix&   identity(void) {return identity(num_rows(),num_cols());}
00076 /*    BGMatrix&   sweep(const size_type i0,const size_type i1); */
00077 /*    BGMatrix&   sweep(void) {return sweep(num_rows() - 1, num_cols() - 1);} */
00078    bool        symmetric(void) const {
00079      if (!me) return false;
00080      for (int i=1; i<nrow; ++i) {
00081        for (int j=0; j<i; ++j) {
00082          if (fabs(me[i][j]-me[j][i])> (fabs(me[i][j]+me[j][i])*SESSION.epsilon) && fabs(me[i][j]-me[j][i]) > SESSION.epsilon) return false;
00083        }
00084      }
00085    return true;
00086   } ;
00087 
00088 protected:
00089   //   int nrow,ncol;
00090   //   BG** me;
00091 };
00092 
00093 } ///////// end of namespace matvec
00094 #endif
00095 

Generated on Thu Jun 16 17:13:38 2005 for Matvec by doxygen1.2.16