src/Matrix/n_matrix.cc
/* There are two flavors of element access operators herein. The one that might
   commonly be used, i.e. mx(i,j), is DIRECTLY accessing the element <i|mx|j>.
   That can save CPU time by avoiding value copying when altering or obtaining
   elements.  Its misuse can lead to trouble in some matrix classes because not
   all matrix elements are stored.  However, for normal arrays all elements are
   stored so there are no  restrictions on elements or element access.

   In constrast, the "get" function returns copies of the element & the "put"
   function checks that the element is being properly set.  Although these
   are slower they are absolutely safe to use.  The put function returns TF
   and will be FALSE if an element is attempted to be set non-hermitian. Note
   that a FALSE put will trigger class matrix (that which external users use)
   to change the matrix type and then procede with the put.
 
   The (i,j) operator is fast but dangerous if one is not careful or doesn't
   know what they are doing.  So, the (i,j) operator is used inside this class
   and other _matrix derived classes for speed, but this is protected from
   use outside - i.e. protected from the typical user. The typical user deals
   with the generic matrix class (class matrix) whose (i,j) operator works
   in "safe" mode.

    Function/Operator                         Result
    -----------------   ------------------------------------------------------
          =             Current (Hermitian) array set equal to input hmx
    (int,int)           Reference to element <i|nmx|j> (Potential Danger)
    get(int,int)        Copy of element <i|nmx|j>      (Safe)
    put(int,int)        Assigns element <i|nmx|j>      (Return FALSE if fails)
    put_h(int,int)      Assigns both <i|nmx|j> & <j|nmx|i> (Return TRUE/FALSE)
    get_block(r,c,R,C)  Returns nmx block of size RxC starting at <r|nmx|c>
    put_block(r,c,mx)   Places mx into nmx at position <r|hmx|c> (TRUE/FALSE)

    Again, note that operations which return TF will trigger class matrix to  
    take appropriate action when they return FALSE.  This usually means that
    the operation cannot be handled by a normal array, but that is unlikely.
    Were it true, the operation is reattempted.                             */
There are two flavors of element access operators herein. The one that might
commonly be used, i.e. mx(i,j), is DIRECTLY accessing the element .
That can save CPU time by avoiding value copying when altering or obtaining
elements.  Its misuse can lead to trouble in some matrix classes because not
all matrix elements are stored.  However, for normal arrays all elements are
stored so there are no  restrictions on elements or element access.

In constrast, the "get" function returns copies of the element & the "put"
function checks that the element is being properly set.  Although these
are slower they are absolutely safe to use.  The put function returns TF
and will be FALSE if an element is attempted to be set non-hermitian. Note
that a FALSE put will trigger class matrix (that which external users use)
to change the matrix type and then procede with the put.

The (i,j) operator is fast but dangerous if one is not careful or doesn't
know what they are doing.  So, the (i,j) operator is used inside this class
and other _matrix derived classes for speed, but this is protected from
use outside - i.e. protected from the typical user. The typical user deals
with the generic matrix class (class matrix) whose (i,j) operator works
in "safe" mode.

Function/Operator                         Result



Again, note that operations which return TF will trigger class matrix to
take appropriate action when they return FALSE.  This usually means that
the operation cannot be handled by a normal array, but that is unlikely.
Were it true, the operation is reattempted.
There are two flavors of element access operators herein . The one that might commonly be used i . e . mx ( i j ) is DIRECTLY accessing the element . That can save CPU time by avoiding value copying when altering or obtaining elements . Its misuse can lead to trouble in some matrix classes because not all matrix elements are stored . However for normal arrays all elements are stored so there are no restrictions on elements or element access . In constrast the " get " function returns copies of the element & the " put " function checks that the element is being properly set . Although these are slower they are absolutely safe to use . The put function returns TF and will be FALSE if an element is attempted to be set non - hermitian . Note that a FALSE put will trigger class matrix ( that which external users use ) to change the matrix type and then procede with the put . The ( i j ) operator is fast but dangerous if one is not careful or doesn ' t know what they are doing . So the ( i j ) operator is used inside this class and other _matrix derived classes for speed but this is protected from use outside - i . e . protected from the typical user . The typical user deals with the generic matrix class ( class matrix ) whose ( i j ) operator works in " safe " mode . Function / Operator Result Again note that operations which return TF will trigger class matrix to take appropriate action when they return FALSE . This usually means that the operation cannot be handled by a normal array but that is unlikely . Were it true the operation is reattempted .
void n_matrix::operator= (const n_matrix& mx)
  {
  if(this == &mx) return; 			
  delete [] data;				
  _matrix::operator= (mx);			
  data = new complex[size];			
  for(int pos=0; pos<size; pos ++)		
    data[pos] = mx.data[pos];
  unitary = mx.unitary;				
  }
void n_matrix :: operator = ( const n_matrix & mx ) { if ( this == & mx ) return ; delete [ ] data ; _matrix :: operator = ( mx ) ; data = new complex [ size ] ; for ( int pos = 0 ; pos < size ; pos ++ ) data [ pos ] = mx . data [ pos ] ; unitary = mx . unitary ; }
There are two flavors of element access operators herein.
There are two flavors of element access operators herein .
// Do nothing on self-assign // First delete the data // Assign by generic function // Construct new data array // Copy the data array // Copy our unitary flag