CPPLapack
 All Classes Files Functions Variables Friends
_zgematrix-calc.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! return transposed zgematrix */
00003 inline _zgematrix t(const _zgematrix& mat)
00004 {VERBOSE_REPORT;
00005   zgematrix 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   mat.destroy();
00014   return _(newmat);
00015 }
00016 
00017 //=============================================================================
00018 /*! return its inverse matrix */
00019 inline _zgematrix i(const _zgematrix& mat)
00020 {VERBOSE_REPORT;
00021 #ifdef  CPPL_DEBUG
00022   if(mat.m!=mat.n){
00023     ERROR_REPORT;
00024     std::cerr << "This matrix is not square and has no inverse matrix." << std::endl
00025               << "Your input was (" << mat.m << "x" << mat.n << ")." << std::endl;
00026     exit(1);
00027   }
00028 #endif//CPPL_DEBUG
00029   zgematrix mat_cp(mat);
00030   zgematrix mat_inv(mat_cp.m,mat_cp.n);
00031   mat_inv.identity();
00032   mat_cp.zgesv(mat_inv);
00033   
00034   return _(mat_inv);
00035 }
00036 
00037 ///////////////////////////////////////////////////////////////////////////////
00038 ///////////////////////////////////////////////////////////////////////////////
00039 ///////////////////////////////////////////////////////////////////////////////
00040 
00041 //=============================================================================
00042 /*! return its conjugate matrix */
00043 inline _zgematrix conj(const _zgematrix& mat)
00044 {VERBOSE_REPORT;
00045   for(long i=0; i<mat.m; i++){ for(long j=0; j<mat.n; j++){
00046     mat(i,j) =std::conj(mat(i,j));
00047   }}
00048   
00049   return mat;
00050 }
00051 
00052 //=============================================================================
00053 /*! return its conjugate transposed matrix */
00054 inline _zgematrix conjt(const _zgematrix& mat)
00055 {VERBOSE_REPORT;
00056   zgematrix newmat(mat.n,mat.m);
00057   for(long i=0; i<newmat.m; i++){
00058     for(long j=0; j<newmat.n; j++){
00059       newmat(i,j) =std::conj(mat(j,i));
00060     }
00061   }
00062   
00063   mat.destroy();
00064   return _(newmat);
00065 }
00066 
00067 ///////////////////////////////////////////////////////////////////////////////
00068 ///////////////////////////////////////////////////////////////////////////////
00069 ///////////////////////////////////////////////////////////////////////////////
00070 
00071 //=============================================================================
00072 /*! search the index of element having the largest absolute value
00073   in 0-based numbering system */
00074 inline void idamax(long& i, long& j, const _zgematrix& mat)
00075 {VERBOSE_REPORT;
00076   long index( izamax_(mat.m*mat.n, mat.array, 1) -1 );
00077   i =index%mat.m;
00078   j =index/mat.m;
00079   
00080   mat.destroy();
00081 }
00082 
00083 //=============================================================================
00084 /*! return its largest absolute value */
00085 inline comple damax(const _zgematrix& mat)
00086 {VERBOSE_REPORT;
00087   comple val( mat.array[izamax_(mat.m*mat.n, mat.array, 1) -1] );
00088   
00089   mat.destroy();
00090   return val;
00091 }
 All Classes Files Functions Variables Friends