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   dgsmatrix newmat(mat);
00006   for(std::vector<dcomponent>::iterator it=newmat.data.begin(); it!=newmat.data.end(); it++){
00007     std::swap(it->i,it->j);
00008   }
00009   std::swap(newmat.rows,newmat.cols);
00010   
00011   return _(newmat);
00012 }
00013 
00014 ///////////////////////////////////////////////////////////////////////////////
00015 ///////////////////////////////////////////////////////////////////////////////
00016 ///////////////////////////////////////////////////////////////////////////////
00017 
00018 //=============================================================================
00019 /*! search the index of element having the largest absolute value
00020   in 0-based numbering system */
00021 inline void idamax(long& i, long& j, const dgsmatrix& mat)
00022 {VERBOSE_REPORT;
00023   std::vector<dcomponent>::const_iterator itx(mat.data.begin());
00024   double vmax =0.;
00025   for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00026     if( vmax < fabs(it->v) ){
00027       vmax =fabs(it->v);
00028       itx =it;
00029     }
00030   }
00031   i =itx->i;
00032   j =itx->j;
00033 }
00034 
00035 //=============================================================================
00036 /*! return its largest absolute value */
00037 inline double damax(const dgsmatrix& mat)
00038 {VERBOSE_REPORT;
00039   std::vector<dcomponent>::const_iterator itx(mat.data.begin());
00040   double vmax =0.;
00041   for(std::vector<dcomponent>::const_iterator it=mat.data.begin(); it!=mat.data.end(); it++){
00042     if( vmax < fabs(it->v) ){
00043       vmax =fabs(it->v);
00044       itx =it;
00045     }
00046   }
00047   return itx->v;
00048 }
 All Classes Files Functions Variables Friends