CPPLapack
 All Classes Files Functions Variables Friends
dgematrix-calc.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! return transposed dgematrix */
00003 inline _dgematrix t(const dgematrix& mat)
00004 {VERBOSE_REPORT;
00005   dgematrix newmat(mat.n,mat.m);
00006   
00007   for(long i=0; i<newmat.m; i++){
00008     for(long j=0; j<newmat.n; j++){
00009       newmat(i,j) =mat(j,i);
00010     }
00011   }
00012   
00013   return _(newmat);
00014 }
00015 
00016 //=============================================================================
00017 /*! return its inverse matrix */
00018 inline _dgematrix i(const dgematrix& mat)
00019 {VERBOSE_REPORT;
00020 #ifdef  CPPL_DEBUG
00021   if(mat.m!=mat.n){
00022     ERROR_REPORT;
00023     std::cerr << "This matrix is not square and has no inverse matrix." << std::endl
00024               << "Your input was (" << mat.m << "x" << mat.n << ")." << std::endl;
00025     exit(1);
00026   }
00027 #endif//CPPL_DEBUG
00028   
00029   dgematrix mat_cp(mat), mat_inv(mat.m,mat.n);
00030   mat_inv.identity();
00031   mat_cp.dgesv(mat_inv);
00032   
00033   return _(mat_inv);
00034 }
00035 
00036 ///////////////////////////////////////////////////////////////////////////////
00037 ///////////////////////////////////////////////////////////////////////////////
00038 ///////////////////////////////////////////////////////////////////////////////
00039 
00040 //=============================================================================
00041 /*! search the index of element having the largest absolute value
00042   in 0-based numbering system */
00043 inline void idamax(long& i, long& j, const dgematrix& mat)
00044 {VERBOSE_REPORT;
00045   long index( idamax_(mat.m*mat.n, mat.array, 1) -1 );
00046   i =index%mat.m;
00047   j =index/mat.m;
00048 }
00049 
00050 //=============================================================================
00051 /*! return its largest absolute value */
00052 inline double damax(const dgematrix& mat)
00053 {VERBOSE_REPORT;
00054   return mat.array[idamax_(mat.m*mat.n, mat.array, 1) -1];
00055 }
 All Classes Files Functions Variables Friends