//=============================================================================
/*! dgsmatrix constructor without arguments */
inline dgsmatrix::dgsmatrix()
: m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx), rows(Rows), cols(Cols)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] dgsmatrix::dgsmatrix()" << std::endl;
#endif//CPPL_VERBOSE
//////// initialize ////////
M =N =0;
CAP =VOL =0;
Array =NULL;
Indx =Jndx =NULL;
Rows =Cols =NULL;
#ifdef CPPL_VERBOSE
std::cerr << "# [NOTE] dgsmatrix::dgsmatrix()" << " A new 0x0 matrix at " << Array << " has been made." << std::endl;
#endif//CPPL_VERBOSE
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! dgsmatrix copy constructor */
inline dgsmatrix::dgsmatrix(const dgsmatrix& mat)
: m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx), rows(Rows), cols(Cols)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] dgsmatrix::dgsmatrix(const dgsmatrix&)" << std::endl;
#endif//CPPL_VERBOSE
Array =NULL;
Indx =Jndx =NULL;
Rows =Cols =NULL;
copy(mat);
#ifdef CPPL_VERBOSE
std::cerr << "# [NOTE] dgsmatrix::dgsmatrix(const dgsmatrix&)" << " A new matrix at " << Array << " has been made." << std::endl;
#endif//CPPL_VERBOSE
}
//=============================================================================
/*! dgsmatrix constructor to cast _dgsmatrix */
inline dgsmatrix::dgsmatrix(const _dgsmatrix& mat)
: m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx), rows(Rows), cols(Cols)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] dgsmatrix::dgsmatrix(const _dgsmatrix&)" << std::endl;
#endif//CPPL_VERBOSE
M =mat.M;
N =mat.N;
CAP =mat.CAP;
VOL =mat.VOL;
Array =mat.Array;
Indx =mat.Indx;
Jndx =mat.Jndx;
Rows =mat.Rows;
Cols =mat.Cols;
mat.nullify();
#ifdef CPPL_VERBOSE
std::cerr << "# [NOTE] dgsmatrix::dgsmatrix(const _dgsmatrix&)" << " A new matrix pointing at " << Array << " has been made." << std::endl;
#endif//CPPL_VERBOSE
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! dgsmatrix constructor with size specification */
inline dgsmatrix::dgsmatrix(const long& _m, const long& _n, const long _c)
: m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx), rows(Rows), cols(Cols)
{
#ifdef CPPL_VERBOSE
std::cerr << "ahoahoaho" << std::endl;
std::cerr << "# [MARK] dgsmatrix::dgsmatrix(const long&, const long&, const long&)" << std::endl;
#endif//CPPL_VERBOSE
#ifdef CPPL_DEBUG
if( _m<0 || _n<0 || _c<0 ){
std::cerr << "[ERROR] dgsmatrix::dgsmatrix(const long&, const long&, const long&)" << std::endl
<< "Matrix sizes and the length of arrays must be positive integers. " << std::endl
<< "Your input was (" << _m << "," << _n << "," << _c << ")." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
//////// initialize ////////
M =_m; N =_n;
CAP =_c;
VOL =0;
Array =new double[CAP];
Indx =new long[CAP];
Jndx =new long[CAP];
Rows =new std::vector< std::pair<long,long> >[M];
Cols =new std::vector< std::pair<long,long> >[N];
#ifdef CPPL_VERBOSE
std::cerr << "# [NOTE] dgsmatrix(const long&, const long&, const long&)" << " A new matrix at " << Array << " has been made." << std::endl;
#endif//CPPL_VERBOSE
}
//=============================================================================
/*! dgsmatrix constructor with filename */
inline dgsmatrix::dgsmatrix(const char* filename)
: m(M), n(N), cap(CAP), vol(VOL), array(Array), indx(Indx), jndx(Jndx), rows(Rows), cols(Cols)
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] dgsmatrix::dgsmatrix(const char*)" << std::endl;
#endif//CPPL_VERBOSE
Array =NULL;
Indx =Jndx =NULL;
Rows =Cols =NULL;
//// read ////
read(filename);
#ifdef CPPL_VERBOSE
std::cerr << "# [NOTE] dgsmatrix::dgsmatrix(const char*)" << " A new matrix at " << Array << " has been made." << std::endl;
#endif//CPPL_VERBOSE
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
/*! dgsmatrix destructor */
inline dgsmatrix::~dgsmatrix()
{
#ifdef CPPL_VERBOSE
std::cerr << "# [MARK] dgsmatrix::~dgsmatrix()" << std::endl;
std::cerr << "# [NOTE] dgsmatrix::~dgsmatrix()" << " A matrix at " << Array << " is going to be deleted." << std::endl;
#endif//CPPL_VERBOSE
delete [] Array;
delete [] Indx;
delete [] Jndx;
delete [] Rows;
delete [] Cols;
}