CPPLapack
 All Classes Files Functions Variables Friends
zgematrix_small-specialized.hpp
Go to the documentation of this file.
00001 //=============================================================================
00002 /*! calculate determinant */
00003 inline comple det(const zgemat2& A)
00004 {VERBOSE_REPORT;
00005   return A(0,0)*A(1,1)-A(0,1)*A(1,0);
00006 }
00007 
00008 //=============================================================================
00009 /*! calculate inverse */
00010 inline zgemat2 inv(const zgemat2& A)
00011 {VERBOSE_REPORT;
00012   const comple Adet( det(A) );
00013   zgemat2 Ainv;
00014   Ainv(0,0)= A(1,1)/Adet;  Ainv(0,1)=-A(0,1)/Adet;
00015   Ainv(1,0)=-A(1,0)/Adet;  Ainv(1,1)= A(0,0)/Adet;
00016   return Ainv;
00017 }
00018 
00019 ///////////////////////////////////////////////////////////////////////////////
00020 ///////////////////////////////////////////////////////////////////////////////
00021 ///////////////////////////////////////////////////////////////////////////////
00022 
00023 //=============================================================================
00024 /*! calculate determinant */
00025 inline comple det(const zgemat3& A)
00026 {VERBOSE_REPORT;
00027   return
00028     +A(0,0)*A(1,1)*A(2,2) -A(0,0)*A(1,2)*A(2,1)
00029     +A(0,1)*A(1,2)*A(2,0) -A(0,1)*A(1,0)*A(2,2)
00030     +A(0,2)*A(1,0)*A(2,1) -A(0,2)*A(1,1)*A(2,0);
00031 }
00032 
00033 //=============================================================================
00034 /*! calculate inverse */
00035 inline zgemat3 inv(const zgemat3& A)
00036 {VERBOSE_REPORT;
00037   const comple Adet( det(A) );
00038   zgemat3 Ainv;
00039   Ainv(0,0) =(A(1,1)*A(2,2)-A(1,2)*A(2,1))/Adet;
00040   Ainv(0,1) =(A(0,2)*A(2,1)-A(0,1)*A(2,2))/Adet;
00041   Ainv(0,2) =(A(0,1)*A(1,2)-A(0,2)*A(1,1))/Adet;
00042   Ainv(1,0) =(A(1,2)*A(2,0)-A(1,0)*A(2,2))/Adet;
00043   Ainv(1,1) =(A(0,0)*A(2,2)-A(0,2)*A(2,0))/Adet;
00044   Ainv(1,2) =(A(0,2)*A(1,0)-A(0,0)*A(1,2))/Adet;
00045   Ainv(2,0) =(A(1,0)*A(2,1)-A(1,1)*A(2,0))/Adet;
00046   Ainv(2,1) =(A(0,1)*A(2,0)-A(0,0)*A(2,1))/Adet;
00047   Ainv(2,2) =(A(0,0)*A(1,1)-A(0,1)*A(1,0))/Adet;
00048   return Ainv;
00049 }
 All Classes Files Functions Variables Friends