src/Matrix/h_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.  However its misuse can lead to trouble in this class because not
   all Hermitian matrix elements are stored and there are restrictions on the
   elements so that the array remains Hermitian.  Two examples of when this is
   trouble would be "hmx(0,0)=comlexi;" and "hmx(2,0)=7".  The former fails as
   diagonal elements MUST be real and the latter fails because lower triangle
   elements are not stored so they don't exist.

   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|hmx|j> (Potential Danger)
    get(int,int)        Copy of element <i|hmx|j>      (Safe)
    put(int,int)        Assigns element <i|hmx|j>      (Return FALSE if fails)
    put_h(int,int)      Assigns both <i|hmx|j> & <j|hmx|i> (Return TRUE/FALSE)
    get_block(r,c,R,C)  Returns hmx block of size RxC starting at <r|hmx|c>
    put_block(r,c,mx)   Places mx into hmx 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 Hermitian array so the array type
    is changed to be more generic.  The 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.  However its misuse can lead to trouble in this class because not
all Hermitian matrix elements are stored and there are restrictions on the
elements so that the array remains Hermitian.  Two examples of when this is
trouble would be "hmx(0,0)=comlexi;" and "hmx(2,0)=7".  The former fails as
diagonal elements MUST be real and the latter fails because lower triangle
elements are not stored so they don't exist.

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 Hermitian array so the array type
is changed to be more generic.  The 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 . However its misuse can lead to trouble in this class because not all Hermitian matrix elements are stored and there are restrictions on the elements so that the array remains Hermitian . Two examples of when this is trouble would be " hmx ( 0 0 ) = comlexi ; " and " hmx ( 2 0 ) = 7 " . The former fails as diagonal elements MUST be real and the latter fails because lower triangle elements are not stored so they don ' t exist . 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 Hermitian array so the array type is changed to be more generic . The the operation is reattempted .
void h_matrix::operator= (const h_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];
  }
void h_matrix :: operator = ( const h_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 ] ; }
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