src/Matrix/n_matrix.cc
_matrix* n_matrix::mxexp()
  {
  _matrix* dmx;					// For eigenvalues
  _matrix* emx;					// For eigenvectors
  diag(dmx, emx);				// Diagonalize mx to dmx & emx 
  complex *d00 = ((d_matrix*)dmx)->data;	// Start of dmx: d00 = <0|dmx|0>
  complex *dii, *dend = d00 + cols_;		// Indexing on dmx diagonal
  for(dii=d00; dii<dend; dii++)			// Effective loop over i
    (*dii) = exp(*dii);				// Set <i|dmx|i> to exp(<i|dmx|i>
//  _matrix* pdt1  = dmx->multiply(emx);		// Perform exp(D)*E
//  _matrix* emxi  = emx->inv();			// Get inverse of emx
//  _matrix* expmx = emxi->multiply(pdt1);	// Perform inv(E)*exp(D)*E

  _matrix* emxi  = emx->inv();			// Get inverse of emx
  _matrix* pdt1  = dmx->multiply(emxi);
  _matrix* expmx = emx->multiply(pdt1);
  delete dmx;                                   // Clean up the dmx matrix
  delete emx;                                   // Clean up the emx matrix
  delete pdt1;					// Clean up the pdt1 matrix
  delete emxi;					// Clean up the emxi matrix
  return expmx;
  }
/*  This curretly uses an eigensystem method for generating the exponential.

                   exp(A) = exp[E*D*inv(E)] = E*exp(D)*inv(E)

    Of course, this will fail when the eigensystem is ill-defined and there
    are other faster ways to approximate the exponential matrix. Hopefully
    later we can find the time to implement some of them too.                */
This curretly uses an eigensystem method for generating the exponential.

Of course, this will fail when the eigensystem is ill-defined and there
are other faster ways to approximate the exponential matrix. Hopefully
later we can find the time to implement some of them too.
This curretly uses an eigensystem method for generating the exponential . Of course this will fail when the eigensystem is ill - defined and there are other faster ways to approximate the exponential matrix . Hopefully later we can find the time to implement some of them too .
_matrix* n_matrix::mxexp()
  {
  _matrix* dmx;					
  _matrix* emx;					
  diag(dmx, emx);				
  complex *d00 = ((d_matrix*)dmx)->data;	
  complex *dii, *dend = d00 + cols_;		
  for(dii=d00; dii<dend; dii++)			
    (*dii) = exp(*dii);				
  _matrix* emxi  = emx->inv();			
  _matrix* pdt1  = dmx->multiply(emxi);
  _matrix* expmx = emx->multiply(pdt1);
  delete dmx;                                   
  delete emx;                                   
  delete pdt1;					
  delete emxi;					
  return expmx;
  }
_matrix * n_matrix :: mxexp ( ) { _matrix * dmx ; _matrix * emx ; diag ( dmx , emx ) ; complex * d00 = ( ( d_matrix * ) dmx ) -> data ; complex * dii , * dend = d00 + cols_ ; for ( dii = d00 ; dii < dend ; dii ++ ) ( * dii ) = exp ( * dii ) ; _matrix * emxi = emx -> inv ( ) ; _matrix * pdt1 = dmx -> multiply ( emxi ) ; _matrix * expmx = emx -> multiply ( pdt1 ) ; delete dmx ; delete emx ; delete pdt1 ; delete emxi ; return expmx ; }
This curretly uses an eigensystem method for generating the exponential.
This curretly uses an eigensystem method for generating the exponential .
// For eigenvalues // For eigenvectors // Diagonalize mx to dmx & emx  // Start of dmx: d00 = <0|dmx|0> // Indexing on dmx diagonal // Effective loop over i // Set <i|dmx|i> to exp(<i|dmx|i> //  _matrix* pdt1  = dmx->multiply(emx);		// Perform exp(D)*E //  _matrix* emxi  = emx->inv();			// Get inverse of emx //  _matrix* expmx = emxi->multiply(pdt1);	// Perform inv(E)*exp(D)*E // Get inverse of emx // Clean up the dmx matrix // Clean up the emx matrix // Clean up the pdt1 matrix // Clean up the emxi matrix