CPPLapack
 All Classes Files Functions Variables Friends
_dgsmatrix-calc.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! return transposed _dgsmatrix */
00003 inline _dgsmatrix t(const _dgsmatrix& mat)
00004 {VERBOSE_REPORT;
00005   for(std::vector<dcomponent>::iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00006     std::swap(it->i,it->j);
00007   }
00008   std::swap(mat.rows,mat.cols);
00009   
00010   return mat;
00011 }
00012 
00013 ///////////////////////////////////////////////////////////////////////////////
00014 ///////////////////////////////////////////////////////////////////////////////
00015 ///////////////////////////////////////////////////////////////////////////////
00016 
00017 //=============================================================================
00018 /*! search the index of element having the largest absolute value
00019   in 0-based numbering system */
00020 inline void idamax(long& i, long& j, const _dgsmatrix& mat)
00021 {VERBOSE_REPORT;
00022   std::vector<dcomponent>::const_iterator itx(mat.data.begin());
00023   double vmax(0);
00024   for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00025     if(vmax < it->v){
00026       vmax=fabs(it->v);
00027       itx=it;
00028     }
00029   }
00030   i=itx->i;
00031   j=itx->j;
00032   
00033   mat.destroy();
00034 }
00035 
00036 //=============================================================================
00037 /*! return its largest absolute value */
00038 inline double damax(const _dgsmatrix& mat)
00039 {VERBOSE_REPORT;
00040   std::vector<dcomponent>::const_iterator itx(mat.data.begin());
00041   double vmax(0);
00042   for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00043     if(vmax < it->v){
00044       vmax=fabs(it->v);
00045       itx=it;
00046     }
00047   }
00048   
00049   mat.destroy();
00050   return itx->v;
00051 }
 All Classes Files Functions Variables Friends