CPPLapack
 All Classes Files Functions Variables Friends
dsymatrix-calc.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! return transposed dgematrix */
00003 inline _dsymatrix t(const dsymatrix& mat)
00004 {VERBOSE_REPORT;
00005 #ifdef  CPPL_DEBUG
00006   WARNING_REPORT;
00007   std::cerr << "This function call has no effect since the matrix is symmetric." << std::endl;
00008 #endif//CPPL_DEBUG
00009   
00010   dsymatrix newmat(mat);
00011   return _(newmat);
00012 }
00013 
00014 //=============================================================================
00015 /*! return its inverse matrix */
00016 inline _dsymatrix i(const dsymatrix& mat)
00017 {VERBOSE_REPORT;
00018   dsymatrix mat_cp(mat);
00019   dsymatrix mat_inv(mat.n);
00020   mat_inv.identity();
00021   
00022   char UPLO('l');
00023   long NRHS(mat.n), LDA(mat.n), *IPIV(new long[mat.n]), LDB(mat.n), LWORK(-1), INFO(1);
00024   double *WORK( new double[1] );
00025   dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
00026   LWORK = long(WORK[0]);
00027   delete [] WORK;  WORK = new double[LWORK];
00028   dsysv_(UPLO, mat.n, NRHS, mat_cp.array, LDA, IPIV, mat_inv.array, LDB, WORK, LWORK, INFO);
00029   delete [] WORK; delete [] IPIV;
00030   if(INFO!=0){
00031     WARNING_REPORT;
00032     std::cerr << "Serious trouble happend. INFO = " << INFO << "." << std::endl;
00033   }
00034   
00035   return _(mat_inv);
00036 }
00037 
00038 
00039 ///////////////////////////////////////////////////////////////////////////////
00040 ///////////////////////////////////////////////////////////////////////////////
00041 ///////////////////////////////////////////////////////////////////////////////
00042 
00043 //=============================================================================
00044 /*! search the index of element having the largest absolute value
00045   in 0-based numbering system */
00046 inline void idamax(long& i, long& j, const dsymatrix& mat)
00047 {VERBOSE_REPORT;
00048   i=j=0;
00049   double val(0.);
00050   for(long J=0; J<mat.n; J++){
00051     long I( J +idamax_(mat.m-J, mat.darray[J]+J, 1) -1 );
00052     if( val<fabs(mat.darray[J][I]) ){
00053       val =fabs(mat.darray[J][I]);
00054       i=I;
00055       j=J;
00056     }
00057   }
00058 }
00059 
00060 //=============================================================================
00061 /*! return its largest absolute value */
00062 inline double damax(const dsymatrix& mat)
00063 {VERBOSE_REPORT;
00064   long i,j;
00065   idamax(i, j, mat);
00066   return mat(i,j);
00067 }
 All Classes Files Functions Variables Friends