CPPLapack
Public Member Functions | Public Attributes | Friends
dsymatrix_small< n > Class Template Reference

Samll Real Double-precision Symmetric Matrix Class. More...

#include <dsymatrix_small.hpp>

List of all members.

Public Member Functions

 dsymatrix_small ()
 dsymatrix_small (const dsymatrix &)
 dsymatrix_small (const double &)
 ~dsymatrix_small ()
dgematrix_small< n, n > to_dgematrix_small () const
dsymatrix to_dsymatrix () const
double & operator() (const long &i, const long &j)
double operator() (const long &i, const long &j) const
dsymatrix_small< n > & set (const long &, const long &, const double &)
void read (const char *filename)
void write (const char *filename) const
dsymatrix_small< n > & zero ()
dsymatrix_small< n > & identity ()
template<long N>
dsymatrix_small< N > & operator= (const dsymatrix_small< N > &)

Public Attributes

double array [(n *(n+1))/2]

Friends

template<long _n>
std::ostream & operator<< (std::ostream &, const dsymatrix_small< _n > &)
template<long N>
dsymatrix_small< N > & operator+= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dsymatrix_small< N > & operator-= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dsymatrix_small< N > & operator*= (dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dsymatrix_small< N > & operator*= (dsymatrix_small< N > &, const double &)
template<long N>
dsymatrix_small< N > & operator/= (dsymatrix_small< N > &, const double &)
template<long N>
const dsymatrix_small< N > & operator+ (const dsymatrix_small< N > &)
template<long N>
dsymatrix_small< N > operator- (const dsymatrix_small< N > &)
template<long N>
dgematrix_small< N, N > operator+ (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
template<long N>
dsymatrix_small< N > operator+ (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dgematrix_small< N, N > operator- (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
template<long N>
dsymatrix_small< N > operator- (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dcovector_small< N > operator* (const dsymatrix_small< N > &, const dcovector_small< N > &)
template<long N>
dgematrix_small< N, N > operator* (const dsymatrix_small< N > &, const dgematrix_small< N, N > &)
template<long N>
dgematrix_small< N, N > operator* (const dsymatrix_small< N > &, const dsymatrix_small< N > &)
template<long N>
dsymatrix_small< N > operator* (const dsymatrix_small< N > &, const double &)
template<long N>
dsymatrix_small< N > operator/ (const dsymatrix_small< N > &, const double &)
template<long N>
dsymatrix_small< N > operator* (const double &, const dsymatrix_small< N > &)

Detailed Description

template<long n>
class dsymatrix_small< n >

Samll Real Double-precision Symmetric Matrix Class.

Definition at line 3 of file dsymatrix_small.hpp.


Constructor & Destructor Documentation

template<long n>
dsymatrix_small< n >::dsymatrix_small ( ) [inline]

Definition at line 4 of file dsymatrix_small-constructors.hpp.

{VERBOSE_REPORT;
  ;
}
template<long n>
dsymatrix_small< n >::dsymatrix_small ( const dsymatrix mat) [inline, explicit]

Definition at line 12 of file dsymatrix_small-constructors.hpp.

References dsymatrix::array, dsymatrix::m, and dsymatrix::n.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if( n!=mat.n ){
    ERROR_REPORT;
    std::cerr << "Matrix sizes must be the same." << std::endl
              << "Your input was " << n << "x" << n << " and " << mat.m << "x" << mat.n << "." << std::endl;
    exit(1);
  }
#endif//CPPL_DEBUG
  
  for(long k=0; k<(n*(n+1))/2; k++){
    array[k] =mat.array[k];;
  }
}
template<long n>
dsymatrix_small< n >::dsymatrix_small ( const double &  x) [inline]

Definition at line 31 of file dsymatrix_small-constructors.hpp.

{VERBOSE_REPORT;
  for(long k=0; k<(n*(n+1))/2; k++){
    array[k] =x;
  }
}
template<long n>
dsymatrix_small< n >::~dsymatrix_small ( ) [inline]

Definition at line 45 of file dsymatrix_small-constructors.hpp.

{VERBOSE_REPORT;
  ;
}

Member Function Documentation

template<long n>
dgematrix_small< n, n > dsymatrix_small< n >::to_dgematrix_small ( ) const [inline]

Definition at line 4 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  dgematrix_small<n,n> newmat;
  for(long i=0; i<n; i++){
    for(long j=0;   j<=i; j++){ newmat(i,j) =(*this)(i,j); }
    for(long j=i+1; j<n;  j++){ newmat(i,j) =(*this)(j,i); }
  }
  return newmat;
}
template<long n>
dsymatrix dsymatrix_small< n >::to_dsymatrix ( ) const [inline]

Definition at line 17 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  dsymatrix newmat(n);
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      newmat(i,j) =(*this)(i,j);
    }
  }
  return newmat;
}
template<long n>
double & dsymatrix_small< n >::operator() ( const long &  i,
const long &  j 
) [inline]

Definition at line 38 of file dsymatrix_small-functions.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(i<j){
    ERROR_REPORT;
    std::cerr << "i<j" << std::endl;
    exit(1);
  }
#endif
  
  //const long I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
  return array[(i*(i+1))/2 +j]; //l storage
}
template<long n>
double dsymatrix_small< n >::operator() ( const long &  i,
const long &  j 
) const [inline]

Definition at line 55 of file dsymatrix_small-functions.hpp.

{VERBOSE_REPORT;
#ifdef  CPPL_DEBUG
  if(i<j){
    ERROR_REPORT;
    std::cerr << "i<j" << std::endl;
    exit(1);
  }
#endif
  
  //const long I(max(i,j)), J(min(i,j)); return array[(I*(I+1))/2 +J];
  return array[(i*(i+1))/2 +j];
}
template<long n>
dsymatrix_small< n > & dsymatrix_small< n >::set ( const long &  i,
const long &  j,
const double &  v 
) [inline]

Definition at line 72 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  (*this)(i,j)=v;
  return *this;
}
template<long n>
void dsymatrix_small< n >::read ( const char *  filename) [inline]

Definition at line 115 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  std::ifstream s(filename);
  if(!s){
    ERROR_REPORT;
    std::cerr << "The file \"" << filename << "\" can not be opened." << std::endl;
    exit(1);
  }
  
  std::string id;
  s >> id;
  if( id != "dsymatrix" && id != "#dsymatrix" ){
    ERROR_REPORT;
    std::cerr << "The type name of the file \"" << filename << "\" is not dsymatrix." << std::endl
              << "Its type name was " << id << " ." << std::endl;
    exit(1);
  }
  
  long _n;
  s >> _n;
  if(n!=_n){
    ERROR_REPORT;
    std::cerr << "Matrix size is invalid." << std::endl;
    exit(1);
  }
  
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++ ){
      s >> operator()(i,j);
    }
  }
  if(s.eof()){
    ERROR_REPORT;
    std::cerr << "There is something is wrong with the file \"" << filename << "\"." << std::endl
              << "Most likely, there is a lack of data components, or a linefeed code or space code is missing at the end of the last line." << std::endl;
    exit(1);
  }
  
  s.close();
}
template<long n>
void dsymatrix_small< n >::write ( const char *  filename) const [inline]

Definition at line 95 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  std::ofstream ofs(filename, std::ios::trunc);
  ofs.setf(std::cout.flags());
  ofs.precision(std::cout.precision());
  ofs.width(std::cout.width());
  ofs.fill(std::cout.fill());
  ofs << "#dsymatrix" << " " << n << std::endl;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      ofs << operator()(i,j) << " ";
    }
    ofs << std::endl;
  }
  ofs.close();
}
template<long n>
dsymatrix_small< n > & dsymatrix_small< n >::zero ( ) [inline]

Definition at line 166 of file dsymatrix_small-functions.hpp.

References i().

{VERBOSE_REPORT;
  for(long i=0; i<n; i++){
    for(long j=0; j<=i; j++){
      (*this)(i,j) =0.;
    }
  }
  return *this;
}
template<long n>
dsymatrix_small< n > & dsymatrix_small< n >::identity ( ) [inline]

Definition at line 179 of file dsymatrix_small-functions.hpp.

{VERBOSE_REPORT;
  zero();
  for(long k=0; k<n; k++){
    (*this)(k,k) =1.;
  }
  return *this;
}
template<long n>
template<long N>
dsymatrix_small<N>& dsymatrix_small< n >::operator= ( const dsymatrix_small< N > &  ) [inline]

Friends And Related Function Documentation

template<long n>
template<long _n>
std::ostream& operator<< ( std::ostream &  ,
const dsymatrix_small< _n > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small<N>& operator+= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small<N>& operator-= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small<N>& operator*= ( dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small<N>& operator*= ( dsymatrix_small< N > &  ,
const double &   
) [friend]
template<long n>
template<long N>
dsymatrix_small<N>& operator/= ( dsymatrix_small< N > &  ,
const double &   
) [friend]
template<long n>
template<long N>
const dsymatrix_small<N>& operator+ ( const dsymatrix_small< N > &  ) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator- ( const dsymatrix_small< N > &  ) [friend]
template<long n>
template<long N>
dgematrix_small<N,N> operator+ ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator+ ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dgematrix_small<N,N> operator- ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator- ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dcovector_small< N > operator* ( const dsymatrix_small< N > &  ,
const dcovector_small< N > &   
) [friend]
template<long n>
template<long N>
dgematrix_small<N,N> operator* ( const dsymatrix_small< N > &  ,
const dgematrix_small< N, N > &   
) [friend]
template<long n>
template<long N>
dgematrix_small<N,N> operator* ( const dsymatrix_small< N > &  ,
const dsymatrix_small< N > &   
) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator* ( const dsymatrix_small< N > &  ,
const double &   
) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator/ ( const dsymatrix_small< N > &  ,
const double &   
) [friend]
template<long n>
template<long N>
dsymatrix_small< N > operator* ( const double &  ,
const dsymatrix_small< N > &   
) [friend]

Member Data Documentation

template<long n>
double dsymatrix_small< n >::array[(n *(n+1))/2]

Definition at line 9 of file dsymatrix_small.hpp.

Referenced by operator*(), operator+=(), and operator-=().


The documentation for this class was generated from the following files:
 All Classes Files Functions Variables Friends