CPPLapack
 All Classes Files Functions Variables Friends
_dgematrix-io.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! operator() for object */
00003 inline double& _dgematrix::operator()(const long& i, const long& j) const
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   if( i<0 || j<0 || m<=i || n<=j ){
00007     ERROR_REPORT;
00008     std::cerr << "The required component is out of the matrix size." << std::endl
00009               << "Your input was (" << i << "," << j << ")." << std::endl;
00010     exit(1);
00011   }
00012 #endif//CPPL_DEBUG
00013   
00014   //double val(array[i+m*j]);
00015   return darray[j][i];
00016 }
00017 
00018 ///////////////////////////////////////////////////////////////////////////////
00019 ///////////////////////////////////////////////////////////////////////////////
00020 ///////////////////////////////////////////////////////////////////////////////
00021 
00022 //=============================================================================
00023 inline std::ostream& operator<<(std::ostream& s, const _dgematrix& mat)
00024 {VERBOSE_REPORT;
00025   for(long i=0; i<mat.m; i++){
00026     for(long j=0; j<mat.n; j++){
00027       s << " " << mat(i,j);
00028     }
00029     s << std::endl;
00030   }
00031   
00032   mat.destroy();
00033   return s;
00034 }
00035 
00036 ///////////////////////////////////////////////////////////////////////////////
00037 ///////////////////////////////////////////////////////////////////////////////
00038 ///////////////////////////////////////////////////////////////////////////////
00039 
00040 //=============================================================================
00041 inline void _dgematrix::write(const char *filename) const
00042 {VERBOSE_REPORT;
00043   std::ofstream ofs(filename, std::ios::trunc);
00044   ofs.setf(std::cout.flags());
00045   ofs.precision(std::cout.precision());
00046   ofs.width(std::cout.width());
00047   ofs.fill(std::cout.fill());
00048   
00049   ofs << "#dgematrix" << " " << m << " " << n << std::endl;
00050   for(long i=0; i<m; i++){
00051     for(long j=0; j<n; j++ ){
00052       ofs << operator()(i,j) << " ";
00053     }
00054     ofs << std::endl;
00055   }
00056   
00057   ofs.close();
00058   destroy();
00059 }
 All Classes Files Functions Variables Friends