PMNS_Base.cxx
//......................................................................
///
/// Rotate the Hamiltonian by the angle theta_ij and phase delta_ij.
///
/// The rotations assume all off-diagonal elements with i > j are zero.
/// This is correct if the order of rotations is chosen appropriately
/// and it speeds up computation by skipping null terms
///
/// @param i,j - the indices of the rotation ij
/// @param Ham - the Hamiltonian to be rotated
///
Rotate the Hamiltonian by the angle theta_ij and phase delta_ij.

The rotations assume all off-diagonal elements with i > j are zero.
This is correct if the order of rotations is chosen appropriately
and it speeds up computation by skipping null terms
Rotate the Hamiltonian by the angle theta_ij and phase delta_ij . The rotations assume all off - diagonal elements with i > j are zero . This is correct if the order of rotations is chosen appropriately and it speeds up computation by skipping null terms
void PMNS_Base::RotateH(int i,int j,std::vector< std::vector<complexD> >& Ham){
  if(fTheta[i][j]==0) return;
  double fSinBuffer = sin(fTheta[i][j]);
  double fCosBuffer = cos(fTheta[i][j]);
  double  fHmsBufferD;
  complexD fHmsBufferC;
  if(i+1<j){
    complexD fExpBuffer = complexD(cos(fDelta[i][j]), -sin(fDelta[i][j]));
    if(i>0){
      for(int k=0; k<i; k++){
        fHmsBufferC = Ham[k][i];
        Ham[k][i] *= fCosBuffer;
        Ham[k][i] += Ham[k][j] * fSinBuffer * conj(fExpBuffer);
        Ham[k][j] *= fCosBuffer;
        Ham[k][j] -= fHmsBufferC * fSinBuffer * fExpBuffer;
      }
      for(int k=i+1; k<j; k++){
        fHmsBufferC = Ham[k][j];
        Ham[k][j] *= fCosBuffer;
        Ham[k][j] -= conj(Ham[i][k]) * fSinBuffer * fExpBuffer;
        Ham[i][k] *= fCosBuffer;
        Ham[i][k] += fSinBuffer * fExpBuffer * conj(fHmsBufferC);
      }
      fHmsBufferC = Ham[i][i];
      fHmsBufferD = real(Ham[j][j]);
      Ham[i][i] *= fCosBuffer * fCosBuffer;
      Ham[i][i] += 2 * fSinBuffer * fCosBuffer * real(Ham[i][j] * conj(fExpBuffer));
      Ham[i][i] += fSinBuffer * Ham[j][j] * fSinBuffer;
      Ham[j][j] *= fCosBuffer * fCosBuffer;
      Ham[j][j] += fSinBuffer * fHmsBufferC * fSinBuffer;
      Ham[j][j] -= 2 * fSinBuffer * fCosBuffer * real(Ham[i][j] * conj(fExpBuffer));
      Ham[i][j] -= 2 * fSinBuffer * real(Ham[i][j] * conj(fExpBuffer)) * fSinBuffer * fExpBuffer;
      Ham[i][j] += fSinBuffer * fCosBuffer * (fHmsBufferD - fHmsBufferC) * fExpBuffer;
    }
    else{
      for(int k=i+1; k<j; k++){
        Ham[k][j] = -conj(Ham[i][k]) * fSinBuffer * fExpBuffer;
        Ham[i][k] *= fCosBuffer;
      }
      fHmsBufferD = real(Ham[i][i]);
      Ham[i][j] = fSinBuffer * fCosBuffer * (Ham[j][j] - fHmsBufferD) * fExpBuffer;
      Ham[i][i] *= fCosBuffer * fCosBuffer;
      Ham[i][i] += fSinBuffer * Ham[j][j] * fSinBuffer;
      Ham[j][j] *= fCosBuffer * fCosBuffer;
      Ham[j][j] += fSinBuffer * fHmsBufferD * fSinBuffer;
    }
  }
  else{
    if(i>0){
      for(int k=0; k<i; k++){
        fHmsBufferC = Ham[k][i];
        Ham[k][i] *= fCosBuffer;
        Ham[k][i] += Ham[k][j] * fSinBuffer;
        Ham[k][j] *= fCosBuffer;
        Ham[k][j] -= fHmsBufferC * fSinBuffer;
      }
      fHmsBufferC = Ham[i][i];
      fHmsBufferD = real(Ham[j][j]);
      Ham[i][i] *= fCosBuffer * fCosBuffer;
      Ham[i][i] += 2 * fSinBuffer * fCosBuffer * real(Ham[i][j]);
      Ham[i][i] += fSinBuffer * Ham[j][j] * fSinBuffer;
      Ham[j][j] *= fCosBuffer * fCosBuffer;
      Ham[j][j] += fSinBuffer * fHmsBufferC * fSinBuffer;
      Ham[j][j] -= 2 * fSinBuffer * fCosBuffer * real(Ham[i][j]);
      Ham[i][j] -= 2 * fSinBuffer * real(Ham[i][j]) * fSinBuffer;
      Ham[i][j] += fSinBuffer * fCosBuffer * (fHmsBufferD - fHmsBufferC);
    }
    else{
      Ham[i][j] = fSinBuffer * fCosBuffer * Ham[j][j];
      Ham[i][i] = fSinBuffer * Ham[j][j] * fSinBuffer;
      Ham[j][j] *= fCosBuffer * fCosBuffer;
    }
  }
}
void PMNS_Base :: RotateH ( int i , int j , std :: vector < std :: vector < complexD > > & Ham ) { if ( fTheta [ i ] [ j ] == 0 ) return ; double fSinBuffer = sin ( fTheta [ i ] [ j ] ) ; double fCosBuffer = cos ( fTheta [ i ] [ j ] ) ; double fHmsBufferD ; complexD fHmsBufferC ; if ( i + 1 < j ) { complexD fExpBuffer = complexD ( cos ( fDelta [ i ] [ j ] ) , - sin ( fDelta [ i ] [ j ] ) ) ; if ( i > 0 ) { for ( int k = 0 ; k < i ; k ++ ) { fHmsBufferC = Ham [ k ] [ i ] ; Ham [ k ] [ i ] *= fCosBuffer ; Ham [ k ] [ i ] += Ham [ k ] [ j ] * fSinBuffer * conj ( fExpBuffer ) ; Ham [ k ] [ j ] *= fCosBuffer ; Ham [ k ] [ j ] -= fHmsBufferC * fSinBuffer * fExpBuffer ; } for ( int k = i + 1 ; k < j ; k ++ ) { fHmsBufferC = Ham [ k ] [ j ] ; Ham [ k ] [ j ] *= fCosBuffer ; Ham [ k ] [ j ] -= conj ( Ham [ i ] [ k ] ) * fSinBuffer * fExpBuffer ; Ham [ i ] [ k ] *= fCosBuffer ; Ham [ i ] [ k ] += fSinBuffer * fExpBuffer * conj ( fHmsBufferC ) ; } fHmsBufferC = Ham [ i ] [ i ] ; fHmsBufferD = real ( Ham [ j ] [ j ] ) ; Ham [ i ] [ i ] *= fCosBuffer * fCosBuffer ; Ham [ i ] [ i ] += 2 * fSinBuffer * fCosBuffer * real ( Ham [ i ] [ j ] * conj ( fExpBuffer ) ) ; Ham [ i ] [ i ] += fSinBuffer * Ham [ j ] [ j ] * fSinBuffer ; Ham [ j ] [ j ] *= fCosBuffer * fCosBuffer ; Ham [ j ] [ j ] += fSinBuffer * fHmsBufferC * fSinBuffer ; Ham [ j ] [ j ] -= 2 * fSinBuffer * fCosBuffer * real ( Ham [ i ] [ j ] * conj ( fExpBuffer ) ) ; Ham [ i ] [ j ] -= 2 * fSinBuffer * real ( Ham [ i ] [ j ] * conj ( fExpBuffer ) ) * fSinBuffer * fExpBuffer ; Ham [ i ] [ j ] += fSinBuffer * fCosBuffer * ( fHmsBufferD - fHmsBufferC ) * fExpBuffer ; } else { for ( int k = i + 1 ; k < j ; k ++ ) { Ham [ k ] [ j ] = - conj ( Ham [ i ] [ k ] ) * fSinBuffer * fExpBuffer ; Ham [ i ] [ k ] *= fCosBuffer ; } fHmsBufferD = real ( Ham [ i ] [ i ] ) ; Ham [ i ] [ j ] = fSinBuffer * fCosBuffer * ( Ham [ j ] [ j ] - fHmsBufferD ) * fExpBuffer ; Ham [ i ] [ i ] *= fCosBuffer * fCosBuffer ; Ham [ i ] [ i ] += fSinBuffer * Ham [ j ] [ j ] * fSinBuffer ; Ham [ j ] [ j ] *= fCosBuffer * fCosBuffer ; Ham [ j ] [ j ] += fSinBuffer * fHmsBufferD * fSinBuffer ; } } else { if ( i > 0 ) { for ( int k = 0 ; k < i ; k ++ ) { fHmsBufferC = Ham [ k ] [ i ] ; Ham [ k ] [ i ] *= fCosBuffer ; Ham [ k ] [ i ] += Ham [ k ] [ j ] * fSinBuffer ; Ham [ k ] [ j ] *= fCosBuffer ; Ham [ k ] [ j ] -= fHmsBufferC * fSinBuffer ; } fHmsBufferC = Ham [ i ] [ i ] ; fHmsBufferD = real ( Ham [ j ] [ j ] ) ; Ham [ i ] [ i ] *= fCosBuffer * fCosBuffer ; Ham [ i ] [ i ] += 2 * fSinBuffer * fCosBuffer * real ( Ham [ i ] [ j ] ) ; Ham [ i ] [ i ] += fSinBuffer * Ham [ j ] [ j ] * fSinBuffer ; Ham [ j ] [ j ] *= fCosBuffer * fCosBuffer ; Ham [ j ] [ j ] += fSinBuffer * fHmsBufferC * fSinBuffer ; Ham [ j ] [ j ] -= 2 * fSinBuffer * fCosBuffer * real ( Ham [ i ] [ j ] ) ; Ham [ i ] [ j ] -= 2 * fSinBuffer * real ( Ham [ i ] [ j ] ) * fSinBuffer ; Ham [ i ] [ j ] += fSinBuffer * fCosBuffer * ( fHmsBufferD - fHmsBufferC ) ; } else { Ham [ i ] [ j ] = fSinBuffer * fCosBuffer * Ham [ j ] [ j ] ; Ham [ i ] [ i ] = fSinBuffer * Ham [ j ] [ j ] * fSinBuffer ; Ham [ j ] [ j ] *= fCosBuffer * fCosBuffer ; } } }
......................................................................
Rotate the Hamiltonian by the angle theta_ij and phase delta_ij.
...................................................................... Rotate the Hamiltonian by the angle theta_ij and phase delta_ij .
// Do nothing if angle is zero // With Delta // General case // Top columns // Middle row and column // Nodes ij // First rotation on j (No top columns) // Middle rows and columns // Nodes ij // Without Delta (No middle rows or columns: j = i+1) // General case // Top columns // Nodes ij // First rotation (theta12)