Main Page | Class List | File List | Class Members | File Members | Related Pages

dgematrix Class Reference

double-precision general matrix class More...

#include <dgematrix.hpp>

List of all members.

Public Member Functions

 dgematrix ()
 dgematrix (const dgematrix &)
 dgematrix (const _dgematrix &)
 dgematrix (const long &, const long &)
 ~dgematrix ()
CPPSL_double operator() (const long &, const long &)
double operator() (const long &, const long &) const
void set (const long &, const long &, const double &) const
void clear ()
void zero ()
void identity ()
void chsign ()
void copy (const dgematrix &)
void shallow_copy (const _dgematrix &)
void resize (const long &, const long &)
void transpose ()
long dgesv (dgematrix &)
long dgesv (dcovector &)
dgematrixoperator= (const dgematrix &)
dgematrixoperator+= (const dgematrix &)
dgematrixoperator-= (const dgematrix &)
dgematrixoperator *= (const dgematrix &)
dgematrixoperator= (const _dgematrix &)
dgematrixoperator+= (const _dgematrix &)
dgematrixoperator-= (const _dgematrix &)
dgematrixoperator *= (const _dgematrix &)
dgematrixoperator *= (const double &)
dgematrixoperator/= (const double &)

Public Attributes

long const & m
 global matrix row size (readable)

long const & n
 global matrix column size (readable)

long const & ml
 local matrix row size (readable)

long const & nl
 local matrix column size (readable)

long *const & desc
 matrix description (readable)

double *const & array
 1D array to store matrix data (readable)


Private Attributes

long M
 global matrix row size (NOT accessible)

long N
 global matrix column size (NOT accessible)

long Ml
 local matrix row size (NOT accessible)

long Nl
 local matrix column size (NOT accessible)

long Desc [9]
 matrix description (NOT accessible)

double * Array
 1D array to store matrix data (NOT accessible)


Friends

class _dgematrix
class dcovector
class _dcovector
class drovector
class _drovector
std::ostream & operator<< (std::ostream &, const dgematrix &)
void swap (dgematrix &, dgematrix &)
_dgematrix t (const dgematrix &)
const dgematrixoperator+ (const dgematrix &)
_dgematrix operator- (const dgematrix &)
_dgematrix operator+ (const dgematrix &, const dgematrix &)
_dgematrix operator+ (const dgematrix &, const _dgematrix &)
_dgematrix operator+ (const _dgematrix &, const dgematrix &)
_dgematrix operator- (const dgematrix &, const dgematrix &)
_dgematrix operator- (const dgematrix &, const _dgematrix &)
_dgematrix operator- (const _dgematrix &, const dgematrix &)
_dgematrix operator * (const dgematrix &, const dgematrix &)
_dgematrix operator * (const dgematrix &, const _dgematrix &)
_dgematrix operator * (const _dgematrix &, const dgematrix &)
_dcovector operator * (const dgematrix &, const dcovector &)
_dcovector operator * (const dgematrix &, const _dcovector &)
_drovector operator * (const drovector &, const dgematrix &)
_drovector operator * (const _drovector &, const dgematrix &)
_dgematrix operator * (const dgematrix &, const double &)
_dgematrix operator * (const double &, const dgematrix &)
_dgematrix operator/ (const dgematrix &, const double &)


Detailed Description

double-precision general matrix class

Definition at line 3 of file dgematrix.hpp.


Constructor & Destructor Documentation

dgematrix::dgematrix  )  [inline]
 

dgematrix constructor without arguments

Definition at line 3 of file dgematrix-constructor.hpp.

References Array, Desc, M, Ml, N, and Nl.

00004   : m(M), n(N), ml(Ml), nl(Nl), desc(Desc), array(Array)
00005 {
00006   //////// initialize ////////
00007   M =N =0;
00008   Ml =Nl =0;
00009   Desc[0]=1; Desc[1]=icontxt; Desc[2]=0; Desc[3]=0; Desc[4]=mb; Desc[5]=nb;
00010   Desc[6]=0; Desc[7]=0; Desc[8]=max(1,Ml);
00011   Array =new double[0];
00012   
00013 #ifdef  CPPSL_DEBUG
00014   std::cerr << "# [NOTE] dgematrix::dgematrix() "
00015             << "A new 0x0 matrix at " << Array
00016             << " has been made." << std::endl;
00017 #endif//CPPSL_DEBUG
00018 }

dgematrix::dgematrix const dgematrix mat  )  [inline]
 

dgematrix copy constructor

Definition at line 26 of file dgematrix-constructor.hpp.

References array, Array, Desc, M, Ml, N, and Nl.

00027   : m(M), n(N), ml(Ml), nl(Nl), desc(Desc), array(Array)
00028 {
00029   //////// initialize ////////
00030   M =mat.M; N =mat.N;
00031   Ml =mat.Ml; Nl =mat.Nl;
00032   for(int i=0; i<9; i++){ Desc[i] =mat.Desc[i]; }
00033   Array =new double[Ml*Nl];
00034   
00035   //////// copy ////////
00036   dcopy_(Ml*Nl, mat.Array, 1, Array, 1);
00037   
00038 #ifdef  CPPSL_DEBUG
00039   std::cerr << "# [NOTE] dgematrix::dgematrix(const dgematrix&) "
00040             << "A new matrix at " << array << " has been made." << std::endl;
00041 #endif//CPPSL_DEBUG
00042 }

dgematrix::dgematrix const _dgematrix mat  )  [inline]
 

dgematrix constructor to cast _dgematrix

Definition at line 46 of file dgematrix-constructor.hpp.

References Array, Desc, M, Ml, N, and Nl.

00047   : m(M), n(N), ml(Ml), nl(Nl), desc(Desc), array(Array)
00048 {
00049   M =mat.M; N =mat.N;
00050   Ml =mat.Ml; Nl =mat.Nl;
00051   for(int i=0; i<9; i++){ Desc[i] =mat.Desc[i]; }
00052   Array =mat.Array;
00053   
00054 #ifdef  CPPSL_DEBUG
00055   std::cerr << "# [NOTE] dgematrix::dgematrix(const _dgematrix&) "
00056             << "A new matrix pointing at " << Array << " has been made."
00057             << std::endl;
00058 #endif//CPPSL_DEBUG
00059 }

dgematrix::dgematrix const long &  _m,
const long &  _n
[inline]
 

dgematrix constructor with size specification

Definition at line 67 of file dgematrix-constructor.hpp.

References array, Array, Desc, M, Ml, N, and Nl.

00068   : m(M), n(N), ml(Ml), nl(Nl), desc(Desc), array(Array)
00069 {
00070 #ifdef  CPPSL_DEBUG
00071   if( _m<0 || _n<0 ){
00072     std::cerr << "[ERROR] dgematrix::dgematrix(const long, const long)"
00073               << std::endl
00074               << "Matrix sizes must be positive integers. " << std::endl
00075               << "Your input was (" << _m << "," << _n << ")." << std::endl;
00076     exit(1);
00077   }
00078 #endif//CPPSL_DEBUG
00079   
00080   //////// initialize ////////
00081   M =_m; N =_n;
00082   Ml =numroc_( M, mb, myrow, 0, nprow );
00083   Nl =numroc_( N, nb, mycol, 0, npcol );
00084   Desc[0]=1; Desc[1]=icontxt; Desc[2]=M; Desc[3]=N; Desc[4]=mb; Desc[5]=nb;
00085   Desc[6]=0; Desc[7]=0; Desc[8]=max(1,Ml);
00086   Array =new double[Ml*Nl];
00087   
00088 #ifdef  CPPSL_DEBUG
00089   std::cerr << "# [NOTE] dgematrix(const long&, const long&) "
00090             << "A new matrix at " << array << " has been made." << std::endl;
00091 #endif//CPPSL_DEBUG
00092 }

dgematrix::~dgematrix  )  [inline]
 

dgematrix destructor

Definition at line 100 of file dgematrix-constructor.hpp.

References Array, and array.

00101 {
00102 #ifdef  CPPSL_DEBUG
00103   std::cerr << "# [NOTE] dgematrix::~dgematrix() "
00104             << "A matrix at " << array
00105             << " is going to be deleted." << std::endl;
00106 #endif//CPPSL_DEBUG
00107   //////// delete array ////////
00108   delete [] Array;
00109 }


Member Function Documentation

CPPSL_double dgematrix::operator() const long &  i,
const long &  j
[inline]
 

operator() for non-const object

Definition at line 3 of file dgematrix-io.hpp.

References Array, Desc, M, and N.

Referenced by identity(), and transpose().

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if( i<0 || j<0 || M<=i || N<=j ){
00007     std::cerr << "[ERROR] dgematrix::operator()(const long&, const long&)"
00008               << std::endl
00009               << "The required component is out of the matrix size."
00010               << std::endl
00011               << "Your input was (" << i << "," << j << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015   
00016   return CPPSL_double( Array, i, j, Desc );
00017 }

double dgematrix::operator() const long &  i,
const long &  j
const [inline]
 

operator() for const object

Definition at line 21 of file dgematrix-io.hpp.

References Array, Desc, M, and N.

00022 {
00023 #ifdef  CPPSL_DEBUG
00024   if( i<0 || j<0 || M<=i || N<=j ){
00025     std::cerr << "[ERROR] dgematrix::operator()(const long&, const long&) const"
00026               << std::endl
00027               << "The required component is out of the matrix size."
00028               << std::endl
00029               << "Your input was (" << i << "," << j << ")." << std::endl;
00030     exit(1);
00031   }
00032 #endif//CPPSL_DEBUG
00033   
00034   double alpha;
00035   pdelget_('A', ' ', alpha, Array, i+1, j+1, Desc);
00036   return alpha;
00037 }

void dgematrix::set const long &  i,
const long &  j,
const double &  v
const [inline]
 

set a variable to the matrix component

Definition at line 45 of file dgematrix-io.hpp.

References Array, Desc, M, and N.

00046 {
00047 #ifdef  CPPSL_DEBUG
00048   if( i<0 || j<0 || M<=i || N<=j ){
00049     std::cerr
00050       << "[ERROR] dgematrix::set(const long&, const long&, const double&)"
00051       << std::endl
00052       << "The required component is out of the matrix size." << std::endl
00053       << "Your input was (" << i << "," << j << ")." << std::endl;
00054     exit(1);
00055   }
00056 #endif//CPPSL_DEBUG
00057   
00058   pdelset_(Array, i+1, j+1, Desc, v);
00059 }

void dgematrix::clear  )  [inline]
 

clear all the matrix data and set the sizes 0

Definition at line 3 of file dgematrix-misc.hpp.

References Array, array, Desc, M, Ml, N, and Nl.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   std::cerr << "# [NOTE] dgematrix::clear() "
00007             << "An array at " << array << " is going to be cleared."
00008             << std::endl;
00009 #endif//CPPSL_DEBUG
00010   
00011   M =N =0;
00012   Ml =Nl =0;
00013   for(int i=0; i<9; i++){ Desc[i]=0; }
00014   delete [] Array;
00015   Array =new double[0];
00016 }

void dgematrix::zero  )  [inline]
 

change the matrix into a zero matrix

Definition at line 20 of file dgematrix-misc.hpp.

References Array, Ml, and Nl.

00021 {
00022   for(long i=0; i<Ml*Nl; i++){ Array[i] =0.0; }
00023 }

void dgematrix::identity  )  [inline]
 

change the matrix into an identity matrix

Definition at line 27 of file dgematrix-misc.hpp.

References Array, M, Ml, N, Nl, and operator()().

00028 {
00029 #ifdef  CPPSL_DEBUG
00030   if(M!=N){
00031     std::cerr << "[ERROR] dgematrix::identity()" << std::endl
00032               << "Only square matrix can be a identity matrix." << std::endl
00033               << "The matrix size was " << M << "x" << N << "." << std::endl;
00034     exit(1);
00035   }
00036 #endif//CPPSL_DEBUG
00037   
00038   for(long i=0; i<Ml*Nl; i++){ Array[i] =0.0; }
00039   for(long i=0; i<M; i++){ operator()(i,i) =1.0; }
00040 }

void dgematrix::chsign  )  [inline]
 

change sign(+/-) of the matrix

Definition at line 44 of file dgematrix-misc.hpp.

References Array, Ml, and Nl.

00045 {
00046   for(long i=0; i<Ml*Nl; i++){ Array[i] =-Array[i]; }
00047 }

void dgematrix::copy const dgematrix mat  )  [inline]
 

make a deep copy of the matrix

Definition at line 51 of file dgematrix-misc.hpp.

References Array, Desc, M, Ml, N, and Nl.

Referenced by operator=().

00052 {
00053 #ifdef  CPPSL_DEBUG
00054   std::cerr << "# [NOTE] dgematrix::copy(const dgematrix&) "
00055             << "A dgematrix at " << Array << " is going to be deleted.";
00056 #endif//CPPSL_DEBUG
00057   
00058   delete [] Array;
00059   M =mat.M; N =mat.N;
00060   Ml =mat.Ml; Nl =mat.Nl;
00061   for(int i=0; i<9; i++){ Desc[i] =mat.Desc[i]; }
00062   Array =new double[Ml*Nl];
00063   dcopy_(Ml*Nl, mat.Array, 1, Array, 1);
00064   
00065 #ifdef  CPPSL_DEBUG
00066   std::cerr << " Then, a COPY of a dgematrix has been cleated at "
00067             << Array << "." << std::endl;
00068 #endif//CPPSL_DEBUG
00069 }

void dgematrix::shallow_copy const _dgematrix mat  )  [inline]
 

make a shallow copy of the matrix
This function is not designed to be used in project codes.

Definition at line 74 of file dgematrix-misc.hpp.

References _dgematrix::Array, Array, _dgematrix::Desc, Desc, _dgematrix::M, M, _dgematrix::Ml, Ml, _dgematrix::N, N, _dgematrix::Nl, and Nl.

Referenced by operator *=(), operator=(), and transpose().

00075 {
00076 #ifdef  CPPSL_DEBUG
00077   std::cerr << "# [NOTE] dgematrix:shallow_copy(const _dgematrix&) "
00078             << "A dgematrix at " << Array << " is going to be deleted, "
00079             << "and point to " << mat.Array << " instead." << std::endl;
00080 #endif//CPPSL_DEBUG
00081 
00082   delete [] Array;
00083   M =mat.M; N =mat.N;
00084   Ml =mat.Ml; Nl =mat.Nl;
00085   for(int i=0; i<9; i++){ Desc[i] =mat.Desc[i]; }
00086   Array =mat.Array;
00087 }

void dgematrix::resize const long &  _m,
const long &  _n
[inline]
 

resize the matrix

Definition at line 91 of file dgematrix-misc.hpp.

References Array, desc, M, Ml, N, and Nl.

00092 {
00093 #ifdef  CPPSL_DEBUG
00094   if( _m<0 || _n<0 ){
00095     std::cerr << "[ERROR] dgematrix::resize(const long&, const long&)"
00096               << std::endl
00097               << "Matrix sizes must be positive integers." << std::endl
00098               << "Your input was (" << _m << "," << _n << ")." << std::endl;
00099     exit(1);
00100   }
00101 #endif//CPPSL_DEBUG
00102   
00103   delete [] Array;
00104   M =_m; N =_n;
00105   Ml =numroc_( M, mb, myrow, 0, nprow );
00106   Nl =numroc_( N, nb, mycol, 0, npcol );
00107   desc[0]=1; desc[1]=icontxt; desc[2]=M; desc[3]=N; desc[4]=mb; desc[5]=nb;
00108   desc[6]=0; desc[7]=0; desc[8]=max(1,Ml);
00109   Array =new double[Ml*Nl];
00110 }

void dgematrix::transpose  )  [inline]
 

transpose itself

Definition at line 3 of file dgematrix-calc.hpp.

References _dgematrix::M, M, _dgematrix::N, N, operator()(), and shallow_copy().

00004 {
00005   _dgematrix newmat(N,M);
00006   
00007   for(long i=0; i<newmat.M; i++){ for(long j=0; j<newmat.N; j++){
00008     newmat(i,j)=operator()(j,i);
00009   }}
00010   
00011   shallow_copy(newmat);
00012 }

long dgematrix::dgesv dgematrix mat  )  [inline]
 

solve A*X=Y using dgesv
The argument is dgematrix Y. Y is overwritten and become the solution X. A is also overwritten and become P*L*U.

Definition at line 5 of file dgematrix-lapack.hpp.

References Array, Desc, M, Ml, and N.

00006 {
00007 #ifdef  CPPSL_DEBUG
00008   if(M!=N || M!=mat.M){
00009     std::cerr << "[ERROR] dgematrix::dgesv(dgematrix&) " << std::endl
00010               << "These two matrices cannot be solved." << std::endl
00011               << "Your input was (" << M << "x" << N << ") and ("
00012               << mat.M << "x" << mat.N << ")." << std::endl;
00013     exit(1);
00014   }
00015 #endif//CPPSL_DEBUG 
00016   long NRHS(mat.N), IA(1), JA(1), *IPIV(new long[Ml+mb]), IB(1), JB(1), INFO(1);
00017   pdgesv_( N, NRHS, Array, IA, JA, Desc, IPIV,
00018            mat.Array, IB, JB, mat.Desc, INFO );
00019   delete [] IPIV;
00020   
00021   if(INFO!=0){
00022     std::cerr << "[WARNING] dgematrix::dgesv(dgematrix&) "
00023               << "Serious trouble happend. INFO = " << INFO << "."
00024               << std::endl;
00025   }
00026   return INFO;
00027 }

long dgematrix::dgesv dcovector vec  )  [inline]
 

solve A*x=y using dgesv
The argument is dcovector y. y is overwritten and become the solution x. A is also overwritten and become P*L*U.

Definition at line 33 of file dgematrix-lapack.hpp.

References dcovector::Array, Array, dcovector::Desc, Desc, dcovector::l, m, Ml, N, and n.

00034 {
00035 #ifdef  CPPSL_DEBUG
00036   if(m!=n || m!=vec.l){
00037     std::cerr << "[ERROR] dgematrix::dgesv(dcovector&) " << std::endl
00038               << "These matrix and vector cannot be solved." << std::endl
00039               << "Your input was (" << m << "x" << n << ") and ("
00040               << vec.l << ")." << std::endl;
00041     exit(1);
00042   }
00043 #endif//CPPSL_DEBUG 
00044   long NRHS(1), IA(1), JA(1), *IPIV(new long[Ml+mb]), IB(1), JB(1), INFO(1);
00045   pdgesv_(N, NRHS, Array, IA, JA, Desc, IPIV,
00046           vec.Array, IB, JB, vec.Desc, INFO);
00047   delete [] IPIV;
00048   
00049   if(INFO!=0){
00050     std::cerr << "[WARNING] dgematrix::dgesv(dcovector&) "
00051               << "Serious trouble happend. INFO = " << INFO << "."
00052               << std::endl;
00053   }
00054   return INFO;
00055 }

dgematrix & dgematrix::operator= const dgematrix mat  )  [inline]
 

dgematrix=dgematrix operator

Definition at line 3 of file dgematrix-dgematrix.hpp.

References Array, and copy().

00004 {
00005 #ifdef  CPPL_DEBUG
00006   std::cerr << "# [NOTE] dgematrix::operator=(const dgematrix&) was called."
00007             << std::endl;
00008 #endif//CPPL_DEBUG
00009   
00010   if(Array!=mat.Array){ // if it is NOT self substitution
00011     copy(mat);
00012   }
00013   return *this;
00014 }

dgematrix & dgematrix::operator+= const dgematrix mat  )  [inline]
 

dgematrix+=dgematrix operator

Definition at line 22 of file dgematrix-dgematrix.hpp.

References Array, M, Ml, N, and Nl.

00023 {
00024 #ifdef  CPPSL_DEBUG
00025   if(N!=mat.N || M!=mat.M){
00026     std::cerr << "[ERROR] dgematrix::operator+=(const dgematrix&)" << std::endl
00027               << "These two matrises can not make a summation." << std::endl
00028               << "Your input was (" << M << "x" << N << ") += ("
00029               << mat.M << "x" << mat.N << ")." << std::endl;
00030     exit(1);
00031   }
00032 #endif//CPPSL_DEBUG
00033   
00034   for(long i=0; i<Ml*Nl; i++){ Array[i]+=mat.Array[i]; }
00035   return *this;
00036 }

dgematrix & dgematrix::operator-= const dgematrix mat  )  [inline]
 

dgematrix operator-=

Definition at line 40 of file dgematrix-dgematrix.hpp.

References Array, M, Ml, N, and Nl.

00041 {
00042 #ifdef  CPPSL_DEBUG
00043   if(N!=mat.N || M!=mat.M){
00044     std::cerr << "[ERROR] dgematrix::operator-=(const dgematrix&)" << std::endl
00045               << "These two matrises can not make a sutraction." << std::endl
00046               << "Your input was (" << M << "x" << N << ") -= ("
00047               << mat.M << "x" << mat.N << ")." << std::endl;
00048     exit(1);
00049   }
00050 #endif//CPPSL_DEBUG
00051   
00052   for(long i=0; i<Ml*Nl; i++){ Array[i]-=mat.Array[i]; }
00053   return *this;
00054 }

dgematrix & dgematrix::operator *= const dgematrix mat  )  [inline]
 

dgematrix operator*=

Definition at line 58 of file dgematrix-dgematrix.hpp.

References _dgematrix::Array, Array, _dgematrix::Desc, Desc, M, N, and shallow_copy().

00059 {
00060 #ifdef  CPPSL_DEBUG
00061   if(N!=mat.M){
00062     std::cerr << "[ERROR] dgematrix::operator*=(const dgematrix&)" << std::endl
00063               << "These two matrises can not make a product." << std::endl
00064               << "Your input was (" << M << "x" << N << ") *= ("
00065               << mat.M << "x" << mat.N << ")." << std::endl;
00066     exit(1);
00067   }
00068 #endif//CPPSL_DEBUG
00069   
00070   _dgematrix newmat( M, mat.N );
00071   pdgemm_( 'N', 'N', M, mat.N, N, 1.0, Array, 1, 1, Desc,
00072            mat.Array, 1, 1, mat.Desc, 0.0, newmat.Array, 1, 1, newmat.Desc );
00073   shallow_copy(newmat);
00074   
00075   return *this;
00076 }

dgematrix & dgematrix::operator= const _dgematrix mat  )  [inline]
 

dgematrix=_dgematrix operator

Definition at line 3 of file dgematrix-_dgematrix.hpp.

References shallow_copy().

00004 {
00005 #ifdef  CPPL_DEBUG
00006   std::cerr << "# [NOTE] dgematrix::operator=(const _dgematrix&) was called."
00007             << std::endl;
00008 #endif//CPPL_DEBUG
00009   
00010   shallow_copy(mat);
00011   return *this;
00012 }

dgematrix & dgematrix::operator+= const _dgematrix mat  )  [inline]
 

dgematrix+=_dgematrix operator

Definition at line 20 of file dgematrix-_dgematrix.hpp.

References _dgematrix::Array, Array, _dgematrix::destroy(), _dgematrix::M, M, Ml, _dgematrix::N, N, and Nl.

00021 {
00022 #ifdef  CPPSL_DEBUG
00023   if(N!=mat.N || M!=mat.M){
00024     std::cerr << "[ERROR] dgematrix::operator+=(const _dgematrix&)" << std::endl
00025               << "These two matrises can not make a summation." << std::endl
00026               << "Your input was (" << M << "x" << N << ") += ("
00027               << mat.M << "x" << mat.N << ")." << std::endl;
00028     exit(1);
00029   }
00030 #endif//CPPSL_DEBUG
00031   
00032   for(long i=0; i<Ml*Nl; i++){ Array[i]+=mat.Array[i]; }
00033   
00034   mat.destroy();
00035   return *this;
00036 }

dgematrix & dgematrix::operator-= const _dgematrix mat  )  [inline]
 

dgematrix-=_dgematrix operator

Definition at line 40 of file dgematrix-_dgematrix.hpp.

References _dgematrix::Array, Array, _dgematrix::destroy(), _dgematrix::M, M, Ml, _dgematrix::N, N, and Nl.

00041 {
00042 #ifdef  CPPSL_DEBUG
00043   if(N!=mat.N || M!=mat.M){
00044     std::cerr << "[ERROR] dgematrix::operator-=(const _dgematrix&)" << std::endl
00045               << "These two matrises can not make a sutraction." << std::endl
00046               << "Your input was (" << M << "x" << N << ") -= ("
00047               << mat.M << "x" << mat.N << ")." << std::endl;
00048     exit(1);
00049   }
00050 #endif//CPPSL_DEBUG
00051   
00052   for(long i=0; i<Ml*Nl; i++){ Array[i]-=mat.Array[i]; }
00053   
00054   mat.destroy();
00055   return *this;
00056 }

dgematrix & dgematrix::operator *= const _dgematrix mat  )  [inline]
 

dgematrix*=_dgematrix operator

Definition at line 60 of file dgematrix-_dgematrix.hpp.

References _dgematrix::Array, Array, _dgematrix::Desc, Desc, M, _dgematrix::M, _dgematrix::N, N, and shallow_copy().

00061 {
00062 #ifdef  CPPSL_DEBUG
00063   if(N!=mat.M){
00064     std::cerr << "[ERROR] dgematrix::operator*=(const _dgematrix&)" << std::endl
00065               << "These two matrises can not make a product." << std::endl
00066               << "Your input was (" << M << "x" << N << ") *= ("
00067               << mat.M << "x" << mat.N << ")." << std::endl;
00068     exit(1);
00069   }
00070 #endif//CPPSL_DEBUG
00071   
00072   _dgematrix newmat( M, mat.N );
00073   pdgemm_( 'N', 'N', M, mat.N, N, 1.0, Array, 1, 1, Desc,
00074            mat.Array, 1, 1, mat.Desc, 0.0, newmat.Array, 1, 1, newmat.Desc );
00075   shallow_copy(newmat);
00076   
00077   return *this;
00078 }

dgematrix & dgematrix::operator *= const double &  d  )  [inline]
 

dgematrix*=double operator

Definition at line 3 of file dgematrix-double.hpp.

References Array, Ml, and Nl.

00004 {
00005   dscal_(Ml*Nl, d, Array, 1);
00006   return *this;
00007 }

dgematrix & dgematrix::operator/= const double &  d  )  [inline]
 

dgematrix/=double operator

Definition at line 11 of file dgematrix-double.hpp.

References Array, Ml, and Nl.

00012 {
00013   dscal_(Ml*Nl, 1./d, Array, 1);
00014   return *this;
00015 }


Friends And Related Function Documentation

friend class _dgematrix [friend]
 

Definition at line 136 of file dgematrix.hpp.

friend class dcovector [friend]
 

Definition at line 139 of file dgematrix.hpp.

friend class _dcovector [friend]
 

Definition at line 140 of file dgematrix.hpp.

friend class drovector [friend]
 

Definition at line 141 of file dgematrix.hpp.

friend class _drovector [friend]
 

Definition at line 142 of file dgematrix.hpp.

std::ostream& operator<< std::ostream &  s,
const dgematrix mat
[friend]
 

Definition at line 67 of file dgematrix-io.hpp.

00068 {
00069   for(long i=0; i<mat.M; i++){
00070     for(long j=0; j<mat.N; j++){
00071       s << " " << mat(i,j);
00072     }
00073     s << std::endl;
00074   }
00075   return s;
00076 }

void swap dgematrix A,
dgematrix B
[friend]
 

swap two matrices

Definition at line 114 of file dgematrix-misc.hpp.

00115 {
00116   long A_M(A.M), A_N(A.N), A_Ml(A.Ml), A_Nl(A.Nl), A_Desc[9];
00117   double* A_Array(A.Array);
00118   A.M=B.M; A.N=B.N; A.Ml=B.Ml; A.Nl=B.Nl;  A.Array=B.Array;
00119   B.M=A_M; B.N=A_N; B.Ml=A_Ml; B.Nl=A_Nl;  B.Array=A_Array;
00120   for(int i=0; i<9; i++){
00121     A_Desc[i] =A.Desc[i];
00122     A.Desc[i] =B.Desc[i];
00123     B.Desc[i] =A_Desc[i];
00124   }
00125 }

_dgematrix t const dgematrix mat  )  [friend]
 

return transposed dgematrix

Definition at line 16 of file dgematrix-calc.hpp.

00017 {
00018   _dgematrix newmat(mat.N,mat.M);
00019   
00020   for(long i=0; i<newmat.M; i++){ for(long j=0; j<newmat.N; j++){
00021     newmat(i,j) =mat(j,i);
00022   }}
00023   
00024   return newmat;
00025 }

const dgematrix& operator+ const dgematrix mat  )  [friend]
 

+dgematrix operator

Definition at line 3 of file dgematrix-unary.hpp.

00004 {
00005   return mat;
00006 }

_dgematrix operator- const dgematrix mat  )  [friend]
 

-dgematrix operator

Definition at line 10 of file dgematrix-unary.hpp.

00011 {
00012   _dgematrix newmat(mat.M,mat.N);
00013   for(long i=0; i<newmat.Ml*newmat.Nl; i++){ newmat.Array[i]=-mat.Array[i]; }
00014   return newmat;
00015 }

_dgematrix operator+ const dgematrix matA,
const dgematrix matB
[friend]
 

dgematrix+dgematrix operator

Definition at line 84 of file dgematrix-dgematrix.hpp.

00085 {
00086 #ifdef  CPPSL_DEBUG
00087   if(matA.N!=matB.N || matA.M!=matB.M){
00088     std::cerr << "[ERROR] operator+(const dgematrix&, const dgematrix&)"
00089               << std::endl
00090               << "These two matrises can not make a summation." << std::endl
00091               << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00092               << matB.M << "x" << matB.N << ")." << std::endl;
00093     exit(1);
00094   }
00095 #endif//CPPSL_DEBUG
00096 
00097   _dgematrix newmat(matA.M,matA.N);
00098   for(long i=0; i<newmat.Ml*newmat.Nl; i++){
00099     newmat.Array[i] =matA.Array[i]+matB.Array[i];
00100   }
00101   
00102   return newmat;
00103 }

_dgematrix operator+ const dgematrix matA,
const _dgematrix matB
[friend]
 

dgematrix+_dgematrix operator

Definition at line 86 of file dgematrix-_dgematrix.hpp.

00087 {
00088 #ifdef  CPPSL_DEBUG
00089   if(matA.N!=matB.N || matA.M!=matB.M){
00090     std::cerr << "[ERROR] operator+(const dgematrix&, const _dgematrix&)"
00091               << std::endl
00092               << "These two matrises can not make a summation." << std::endl
00093               << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00094               << matB.M << "x" << matB.N << ")." << std::endl;
00095     exit(1);
00096   }
00097 #endif//CPPSL_DEBUG
00098 
00099   for(long i=0; i<matA.Ml*matA.Nl; i++){ matB.Array[i] +=matA.Array[i]; }
00100   
00101   return matB;
00102 }

_dgematrix operator+ const _dgematrix matA,
const dgematrix matB
[friend]
 

_dgematrix+dgematrix operator

Definition at line 3 of file _dgematrix-dgematrix.hpp.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if(matA.N!=matB.N || matA.M!=matB.M){
00007     std::cerr << "[ERROR] operator+(const _dgematrix&, const dgematrix&)"
00008               << std::endl
00009               << "These two matrises can not make a summation." << std::endl
00010               << "Your input was (" << matA.M << "x" << matA.N << ") + ("
00011               << matB.M << "x" << matB.N << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015 
00016   for(long i=0; i<matA.Ml*matA.Nl; i++){ matA.Array[i] +=matB.Array[i]; }
00017   
00018   return matA;
00019 }

_dgematrix operator- const dgematrix matA,
const dgematrix matB
[friend]
 

dgematrix-dgematrix operator

Definition at line 107 of file dgematrix-dgematrix.hpp.

00108 {
00109 #ifdef  CPPSL_DEBUG
00110   if(matA.N!=matB.N || matA.M!=matB.M){
00111     std::cerr << "[ERROR] operator-(const dgematrix&, const dgematrix&)"
00112               << std::endl
00113               << "These two matrises can not make a subtraction." << std::endl
00114               << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00115               << matB.M << "x" << matB.N << ")." << std::endl;
00116     exit(1);
00117   }
00118 #endif//CPPSL_DEBUG
00119   
00120   _dgematrix newmat(matA.M,matA.N);
00121   for(long i=0; i<newmat.Ml*newmat.Nl; i++){
00122     newmat.Array[i] =matA.Array[i]-matB.Array[i];
00123   }
00124   
00125   return newmat;
00126 }

_dgematrix operator- const dgematrix matA,
const _dgematrix matB
[friend]
 

dgematrix-_dgematrix operator

Definition at line 106 of file dgematrix-_dgematrix.hpp.

00107 {
00108 #ifdef  CPPSL_DEBUG
00109   if(matA.N!=matB.N || matA.M!=matB.M){
00110     std::cerr << "[ERROR] operator-(const dgematrix&, const _dgematrix&)"
00111               << std::endl
00112               << "These two matrises can not make a subtraction." << std::endl
00113               << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00114               << matB.M << "x" << matB.N << ")." << std::endl;
00115     exit(1);
00116   }
00117 #endif//CPPSL_DEBUG
00118   
00119   for(long i=0; i<matA.Ml*matA.Nl; i++){
00120     matB.Array[i] =matA.Array[i]-matB.Array[i];
00121   }
00122   
00123   return matB;
00124 }

_dgematrix operator- const _dgematrix matA,
const dgematrix matB
[friend]
 

_dgematrix-dgematrix operator

Definition at line 23 of file _dgematrix-dgematrix.hpp.

00024 {
00025 #ifdef  CPPSL_DEBUG
00026   if(matA.N!=matB.N || matA.M!=matB.M){
00027     std::cerr << "[ERROR] operator-(const _dgematrix&, const dgematrix&)"
00028               << std::endl
00029               << "These two matrises can not make a subtraction." << std::endl
00030               << "Your input was (" << matA.M << "x" << matA.N << ") - ("
00031               << matB.M << "x" << matB.N << ")." << std::endl;
00032     exit(1);
00033   }
00034 #endif//CPPSL_DEBUG
00035   
00036   for(long i=0; i<matA.Ml*matA.Nl; i++){ matA.Array[i] -=matB.Array[i]; }
00037   
00038   return matA;
00039 }

_dgematrix operator * const dgematrix matA,
const dgematrix matB
[friend]
 

dgematrix*dgematrix operator

Definition at line 130 of file dgematrix-dgematrix.hpp.

00131 {
00132 #ifdef  CPPSL_DEBUG
00133   if(matA.N!=matB.M){
00134     std::cerr << "[ERROR] operator*(const dgematrix&, const dgematrix&)"
00135               << std::endl
00136               << "These two matrises can not make a product." << std::endl
00137               << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00138               << matB.M << "x" << matB.N << ")." << std::endl;
00139     exit(1);
00140   }
00141 #endif//CPPSL_DEBUG
00142   
00143   _dgematrix newmat( matA.M, matB.N );
00144   pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00145            matA.Array, 1, 1, matA.Desc,
00146            matB.Array, 1, 1, matB.Desc, 0.0,
00147            newmat.Array, 1, 1, newmat.Desc );
00148   
00149   return newmat;
00150 }

_dgematrix operator * const dgematrix matA,
const _dgematrix matB
[friend]
 

dgematrix*_dgematrix operator

Definition at line 128 of file dgematrix-_dgematrix.hpp.

00129 {
00130 #ifdef  CPPSL_DEBUG
00131   if(matA.N!=matB.M){
00132     std::cerr << "[ERROR] operator*(const dgematrix&, const _dgematrix&)"
00133               << std::endl
00134               << "These two matrises can not make a product." << std::endl
00135               << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00136               << matB.M << "x" << matB.N << ")." << std::endl;
00137     exit(1);
00138   }
00139 #endif//CPPSL_DEBUG
00140   
00141   _dgematrix newmat( matA.M, matB.N );
00142   pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00143            matA.Array, 1, 1, matA.Desc,
00144            matB.Array, 1, 1, matB.Desc, 0.0,
00145            newmat.Array, 1, 1, newmat.Desc );
00146   
00147   matB.destroy();
00148   return newmat;
00149 }

_dgematrix operator * const _dgematrix matA,
const dgematrix matB
[friend]
 

_dgematrix*dgematrix operator

Definition at line 43 of file _dgematrix-dgematrix.hpp.

00044 {
00045 #ifdef  CPPSL_DEBUG
00046   if(matA.N!=matB.M){
00047     std::cerr << "[ERROR] operator*(const _dgematrix&, const dgematrix&)"
00048               << std::endl
00049               << "These two matrises can not make a product." << std::endl
00050               << "Your input was (" << matA.M << "x" << matA.N << ") * ("
00051               << matB.M << "x" << matB.N << ")." << std::endl;
00052     exit(1);
00053   }
00054 #endif//CPPSL_DEBUG
00055   
00056   _dgematrix newmat( matA.M, matB.N );
00057   pdgemm_( 'N', 'N', matA.M, matB.N, matA.N, 1.0,
00058            matA.Array, 1, 1, matA.Desc,
00059            matB.Array, 1, 1, matB.Desc, 0.0,
00060            newmat.Array, 1, 1, newmat.Desc );
00061   
00062   matA.destroy();
00063   return newmat;
00064 }

_dcovector operator * const dgematrix mat,
const dcovector vec
[friend]
 

dgematrix*dcovector operator

Definition at line 3 of file dgematrix-dcovector.hpp.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if(mat.N!=vec.L){
00007     std::cerr << "[ERROR] operator*(const dgematrix&, const dcovector&)"
00008               << std::endl
00009               << "These matrix and vector can not make a product." << std::endl
00010               << "Your input was (" << mat.m << "x" << mat.n << ") * ("
00011               << vec.l << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015   
00016   _dcovector newvec(mat.M);
00017   pdgemv_( 'N', mat.M, mat.N, 1.0, mat.Array, 1, 1, mat.Desc,
00018            vec.Array, 1, 1, vec.Desc, 1, 0.0,
00019            newvec.Array, 1, 1, newvec.Desc, 1 );
00020   
00021   return newvec;
00022 }

_dcovector operator * const dgematrix mat,
const _dcovector vec
[friend]
 

dgematrix*_dcovector operator

Definition at line 3 of file dgematrix-_dcovector.hpp.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if(mat.N!=vec.L){
00007     std::cerr << "[ERROR] operator*(const dgematrix&, const _dcovector&)"
00008               << std::endl
00009               << "These matrix and vector can not make a product." << std::endl
00010               << "Your input was (" << mat.M << "x" << mat.N << ") * ("
00011               << vec.L << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015   
00016   _dcovector newvec(mat.M);
00017   pdgemv_( 'N', mat.M, mat.N, 1.0, mat.Array, 1, 1, mat.Desc,
00018            vec.Array, 1, 1, vec.Desc, 1, 0.0,
00019            newvec.Array, 1, 1, newvec.Desc, 1 );
00020   
00021   vec.destroy();
00022   return newvec;
00023 }

_drovector operator * const drovector vec,
const dgematrix mat
[friend]
 

drovector*dgematrix operator

Definition at line 3 of file drovector-dgematrix.hpp.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if( vec.L!=mat.M ){
00007     std::cerr << "[ERROR] operator*(const drovector&, const dgematrix&)"
00008               << std::endl
00009               << "These vector and matrix can not make a product." << std::endl
00010               << "Your input was (" << vec.L << ") * ("
00011               << mat.M << "x" << mat.N << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015   
00016   _drovector newvec(mat.N);
00017   pdgemv_( 'T', mat.M, mat.N, 1.0, mat.Array, 1, 1, mat.Desc,
00018            vec.Array, 1, 1, vec.Desc, 1, 0.0,
00019            newvec.Array, 1, 1, newvec.Desc, 1 );
00020   
00021   return newvec;
00022 }

_drovector operator * const _drovector vec,
const dgematrix mat
[friend]
 

_drovector*dgematrix operator

Definition at line 3 of file _drovector-dgematrix.hpp.

00004 {
00005 #ifdef  CPPSL_DEBUG
00006   if( vec.L!=mat.M ){
00007     std::cerr << "[ERROR] operator*(const _drovector&, const dgematrix&)"
00008               << std::endl
00009               << "These vector and matrix can not make a product." << std::endl
00010               << "Your input was (" << vec.L << ") * ("
00011               << mat.M << "x" << mat.N << ")." << std::endl;
00012     exit(1);
00013   }
00014 #endif//CPPSL_DEBUG
00015   
00016   _drovector newvec(mat.N);
00017   pdgemv_( 'T', mat.M, mat.N, 1.0, mat.Array, 1, 1, mat.Desc,
00018            vec.Array, 1, 1, vec.Desc, 1, 0.0,
00019            newvec.Array, 1, 1, newvec.Desc, 1 );
00020   
00021   vec.destroy();
00022   return newvec;
00023 }

_dgematrix operator * const dgematrix mat,
const double &  d
[friend]
 

dgematrix*double operator

Definition at line 23 of file dgematrix-double.hpp.

00024 {
00025   _dgematrix newmat(mat.M, mat.N);
00026   for(int i=0; i<mat.Ml*mat.Nl; i++){ newmat.Array[i] =mat.Array[i]*d; }
00027   
00028   return newmat;
00029 }

_dgematrix operator * const double &  d,
const dgematrix mat
[friend]
 

double*dgematrix operator

Definition at line 3 of file double-dgematrix.hpp.

00004 {
00005   _dgematrix newmat(mat.M, mat.N);
00006   for(int i=0; i<mat.Ml*mat.Nl; i++){ newmat.Array[i] =d*mat.Array[i]; }
00007   
00008   return newmat;
00009 }

_dgematrix operator/ const dgematrix mat,
const double &  d
[friend]
 

dgematrix/double operator

Definition at line 33 of file dgematrix-double.hpp.

00034 {
00035   double inv_d(1./d);
00036   
00037   _dgematrix newmat(mat.M, mat.N);
00038   for(int i=0; i<mat.Ml*mat.Nl; i++){ newmat.Array[i] =mat.Array[i]*inv_d; }
00039   
00040   return newmat;
00041 }


Member Data Documentation

long dgematrix::M [private]
 

global matrix row size (NOT accessible)

Definition at line 7 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), clear(), copy(), dgematrix(), dgesv(), identity(), operator *(), operator *=(), operator()(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator<<(), resize(), set(), shallow_copy(), swap(), t(), and transpose().

long dgematrix::N [private]
 

global matrix column size (NOT accessible)

Definition at line 8 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), clear(), copy(), dgematrix(), dgesv(), identity(), operator *(), operator *=(), operator()(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator<<(), resize(), set(), shallow_copy(), swap(), t(), and transpose().

long dgematrix::Ml [private]
 

local matrix row size (NOT accessible)

Definition at line 9 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), chsign(), clear(), copy(), dgematrix(), dgesv(), identity(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), resize(), shallow_copy(), swap(), and zero().

long dgematrix::Nl [private]
 

local matrix column size (NOT accessible)

Definition at line 10 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), chsign(), clear(), copy(), dgematrix(), identity(), operator *(), operator *=(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), resize(), shallow_copy(), swap(), and zero().

long dgematrix::Desc[9] [private]
 

matrix description (NOT accessible)

Definition at line 11 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), clear(), copy(), dgematrix(), dgesv(), operator *(), operator *=(), operator()(), set(), shallow_copy(), and swap().

double* dgematrix::Array [private]
 

1D array to store matrix data (NOT accessible)

Definition at line 12 of file dgematrix.hpp.

Referenced by _dgematrix::_dgematrix(), _dgematrix::absorb(), chsign(), clear(), copy(), dgematrix(), dgesv(), identity(), operator *(), operator *=(), operator()(), operator+(), operator+=(), operator-(), operator-=(), operator/(), operator/=(), operator=(), resize(), set(), shallow_copy(), swap(), zero(), and ~dgematrix().

long const& dgematrix::m
 

global matrix row size (readable)

Definition at line 16 of file dgematrix.hpp.

Referenced by dgesv(), and operator *().

long const& dgematrix::n
 

global matrix column size (readable)

Definition at line 17 of file dgematrix.hpp.

Referenced by dgesv(), and operator *().

long const& dgematrix::ml
 

local matrix row size (readable)

Definition at line 18 of file dgematrix.hpp.

long const& dgematrix::nl
 

local matrix column size (readable)

Definition at line 19 of file dgematrix.hpp.

long* const& dgematrix::desc
 

matrix description (readable)

Definition at line 20 of file dgematrix.hpp.

Referenced by resize().

double* const& dgematrix::array
 

1D array to store matrix data (readable)

Definition at line 21 of file dgematrix.hpp.

Referenced by clear(), dgematrix(), and ~dgematrix().


The documentation for this class was generated from the following files:
Generated on Sat Jan 31 19:25:46 2004 for CPPScaLapack by doxygen 1.3.5