src/Matrix/n_matrix.cc
// ____________________________________________________________________________
// G              CLASS N_MATRIX UNARY ARITHMETIC FUNCTIONS
// ____________________________________________________________________________
G              CLASS N_MATRIX UNARY ARITHMETIC FUNCTIONS
G CLASS N_MATRIX UNARY ARITHMETIC FUNCTIONS
_matrix* n_matrix::add_two(_matrix* mx)
  {
  if((mx->stored_type()) == n_matrix_type)	 
    { 
    if((rows_!=mx->rows()) || (cols_!=mx->cols()))
      {
      NMxerror(51,1);				
      NMxfatal(20);				
      }
    complex *a=&((n_matrix*)mx)->data[size-1];	
    complex *b = &data[size-1];			
    for(; b>=data ;b--,a--)			
      (*a) += (*b);
    ((n_matrix*)mx)->unitary = false;		
    return mx;
    }
  else						
    return add(mx); 				
  }
_matrix * n_matrix :: add_two ( _matrix * mx ) { if ( ( mx -> stored_type ( ) ) == n_matrix_type ) { if ( ( rows_ != mx -> rows ( ) ) || ( cols_ != mx -> cols ( ) ) ) { NMxerror ( 51 , 1 ) ; NMxfatal ( 20 ) ; } complex * a = & ( ( n_matrix * ) mx ) -> data [ size - 1 ] ; complex * b = & data [ size - 1 ] ; for ( ; b >= data ; b -- , a -- ) ( * a ) += ( * b ) ; ( ( n_matrix * ) mx ) -> unitary = false ; return mx ; } else return add ( mx ) ; }
____________________________________________________________________________
G              CLASS N_MATRIX UNARY ARITHMETIC FUNCTIONS
____________________________________________________________________________
____________________________________________________________________________ G CLASS N_MATRIX UNARY ARITHMETIC FUNCTIONS ____________________________________________________________________________
// Input                nmx  : Input normal matrix (this) //			mx   : Second matrix // Output               mx   : Matrix mx is added into nmx // Note			     : This is the implementation of mx += nmx // Add two n_matrices //    Mismatched dimensions //    Cannot perform addition // Pointer to last element of mx // Pointer to last element of this // Perform addition elementwise // This is probably not unitary now // Add n_matrix to non-n_matrix, since // matrix type changes, result has to be