00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021
00022 #ifndef MATVEC_DOUBLE_MATRIX_H
00023 #define MATVEC_DOUBLE_MATRIX_H
00024 #include "session.h"
00025 #include "matrix.h"
00026
00027 namespace matvec {
00028 class doubleMatrix : public Matrix<double> {
00029 friend class Model;
00030 public:
00031 doubleMatrix(void) : Matrix<double>() {}
00032 explicit doubleMatrix(const size_type m,const size_type n) : Matrix<double>(m,n) {}
00033 doubleMatrix(const size_type m,const size_type n,const double** a) : Matrix<double>(m,n,a) {}
00034 doubleMatrix(const doubleMatrix& a) : Matrix<double>(a) { }
00035 doubleMatrix(const Matrix<double>& a) : Matrix<double>(a) { }
00036
00037 doubleMatrix& operator = (const Matrix<double> &a) { copy(a); return *this; }
00038 doubleMatrix& operator = (const Matrix<bool> &a);
00039
00040 bool psd(void) const;
00041 void svd(doubleMatrix& u,Vector<double>& s,doubleMatrix& v);
00042 int rank(void);
00043 doubleMatrix& inv();
00044 doubleMatrix ginv0(void) const;
00045 doubleMatrix splines(const doubleMatrix knots,const unsigned type=0) const;
00046 doubleMatrix& ginv1(unsigned *irank=0);
00047 doubleMatrix mat_log(double tol=0) const;
00048 doubleMatrix mat_exp(double tol=0) const;
00049 void mat_exp_der(Vector<doubleMatrix> &der,double tol=0) const;
00050 doubleMatrix covariance(const doubleMatrix &B) const;
00051 Vector<double> variance(orientation orien = COLUMN) const;
00052 doubleMatrix lu_solve(const doubleMatrix& rhs);
00053 Vector<double> lu_solve(const Vector<double>& rhs);
00054 void gs_solve(const doubleMatrix& v,doubleMatrix& solmat,const double relax=1.0,
00055 const double stopval=0.001,const int mxiter=1000);
00056 void gs_solve(const Vector<double>& v,Vector<double>& solvec,const double relax=1.0,
00057 const double stopval=0.001,const int mxiter=1000);
00058
00059 Vector<double> eigen(const int job=1);
00060 double cond(void);
00061 double det(void) const;
00062 double norm(const int p) const;
00063 double norm(const std::string &s) const;
00064 double logdet(void);
00065 double quadratic(const Vector<double> &a,const Vector<double> &b) const;
00066 doubleMatrix& sqrtm(void);
00067 doubleMatrix& identity(const int m,const int n);
00068 doubleMatrix& identity(const int m) {return identity(m,m);}
00069 doubleMatrix& identity(void) {return identity(num_rows(),num_cols());}
00070 doubleMatrix& sweep(const size_type i0,const size_type i1);
00071 doubleMatrix& sweep(void) {return sweep(num_rows() - 1, num_cols() - 1);}
00072 bool symmetric(void) const {if (!me) return false;
00073 for (int i=1; i<nrow; ++i) for (int j=0; j<i; ++j) 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;
00074 return true;
00075 } ;
00076
00077 protected:
00078
00079
00080 };
00081
00082 }
00083 #endif
00084