src/LSLib/DensOp.cc
// Input                Sigma	: A density operator (this)
//			tr	: Value for Sigma trace
// Output		void    : Sets Sigma trace to be tr
Input                Sigma     : A density operator (this)
tr      : Value for Sigma trace
Output         void    : Sets Sigma trace to be tr
Input Sigma : A density operator ( this ) tr : Value for Sigma trace Output void : Sets Sigma trace to be tr
void densop::SetTrace(double tr)
  {
  double acttr = Re(trace(*this));	
  double difftr = acttr - tr;		
  int hs = size();			
  complex z;				
  double fact;				
  int i;				
  if(difftr)				
    {					
    fact = difftr/double(hs);
    for(i=0; i<hs; i++)
      {  
      z = get(i,i) - fact;
      put(z, i,i);
      }  
    }  
  }
void densop :: SetTrace ( double tr ) { double acttr = Re ( trace ( * this ) ) ; double difftr = acttr - tr ; int hs = size ( ) ; complex z ; double fact ; int i ; if ( difftr ) { fact = difftr / double ( hs ) ; for ( i = 0 ; i < hs ; i ++ ) { z = get ( i , i ) - fact ; put ( z , i , i ) ; } } }
Input                Sigma     : A density operator (this)
tr      : Value for Sigma trace
Output         void    : Sets Sigma trace to be tr
Input Sigma : A density operator ( this ) tr : Value for Sigma trace Output void : Sets Sigma trace to be tr
// Get current trace // Get trace adjustment // Get Sigma Hilbert space // Temp value // Temp value // Temp value // Adjust all diagonal  // elements to fix trace