src/Matrix/n_matrix.cc
// Note: Due to the length of the inversion algorithm and associated functions,
//       some reside in the file n_matrix_inv.cc.  These are listed below but
//       commented out.
Due to the length of the inversion algorithm and associated functions,
some reside in the file n_matrix_inv.cc.  These are listed below but
commented out.
Due to the length of the inversion algorithm and associated functions some reside in the file n_matrix_inv . cc . These are listed below but commented out .
_matrix* n_matrix::inv()
  {
  if(unitary) return adjoint();			
  int nd = rows_;				
  if(nd != cols_)
    {
    NMxerror(14,1);				
    NMxfatal(25);				
    }
  int *indx;
  indx = new int[nd];
  n_matrix* nLU = new n_matrix(*this);          
  nLU->LU_decomp(indx);                         
  n_matrix* I = new n_matrix(nd,nd,complex0);   
  for(int i=0; i<nd; i++) I->put(complex1,i,i); 
  _matrix* mxinv = I->LUinv(indx,nLU);          
  delete nLU;                                   
  delete I;                                     
  delete [] indx;
  return mxinv;                                 
  }
_matrix * n_matrix :: inv ( ) { if ( unitary ) return adjoint ( ) ; int nd = rows_ ; if ( nd != cols_ ) { NMxerror ( 14 , 1 ) ; NMxfatal ( 25 ) ; } int * indx ; indx = new int [ nd ] ; n_matrix * nLU = new n_matrix ( * this ) ; nLU -> LU_decomp ( indx ) ; n_matrix * I = new n_matrix ( nd , nd , complex0 ) ; for ( int i = 0 ; i < nd ; i ++ ) I -> put ( complex1 , i , i ) ; _matrix * mxinv = I -> LUinv ( indx , nLU ) ; delete nLU ; delete I ; delete [ ] indx ; return mxinv ; }
Note: Due to the length of the inversion algorithm and associated functions,
some reside in the file n_matrix_inv.cc.
Note : Due to the length of the inversion algorithm and associated functions some reside in the file n_matrix_inv . cc .
// Input            nmx : An n_matrix (this) // Output          ninv : Inverse of nmx as defined by //			         nmx * ninv = I // Note			: The algorithm solves for the inverse //			  using an LU decomposition of hmx as per //			      nmx * ninv = LU * ninv = I //			  by first generating I and LU then back //			  substituting to produce ninv // This is real new (sosi) // Matrix dimension //    Bad rectangular array use //    Cannot take inverse // Copy input array for LU decomp // LU decomposition of nLU // Constuct a new n_matrix // Make it the identity matrix // Back solve for inverse // Clean up the nLU matrix // Clean up the I matrix // Return the inverse of nmx