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