//=============================================================================
/*! operator() for object */
inline double& _dgematrix::operator()(const CPPL_INT& i, const CPPL_INT& j) const
{CPPL_VERBOSE_REPORT;
#ifdef CPPL_DEBUG
if( i<0 || j<0 || m<=i || n<=j ){
ERROR_REPORT;
std::cerr << "The required component is out of the matrix size." << std::endl
<< "Your input is (" << i << "," << j << "), whereas the matrix size is " << m << "x" << n << "." << std::endl;
exit(1);
}
#endif//CPPL_DEBUG
//double val(array[i+m*j]);
return darray[j][i];
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
inline std::ostream& operator<<(std::ostream& s, const _dgematrix& mat)
{CPPL_VERBOSE_REPORT;
for(CPPL_INT i=0; i<mat.m; i++){
for(CPPL_INT j=0; j<mat.n; j++){
s << " " << mat(i,j);
}
s << std::endl;
}
mat.destroy();
return s;
}
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
///////////////////////////////////////////////////////////////////////////////
//=============================================================================
inline void _dgematrix::write(const char *filename) const
{CPPL_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 << "#dgematrix" << " " << m << " " << n << std::endl;
for(CPPL_INT i=0; i<m; i++){
for(CPPL_INT j=0; j<n; j++ ){
ofs << operator()(i,j) << " ";
}
ofs << std::endl;
}
ofs.close();
destroy();
}