src/Level2/TrnsTable1D.cc
// Input	TT1	: A transitions table
// 		TT2	: Another transitions table
//              res	: Resolution (in radians/sec)
// Output	TT	: Transitions table which is a blend of
//			  the transitions from TT1 & TT2.  Transitions
//			  within res frequency from one another are
//			  blended into a single transition with a 
//			  summed intensity and weighted frequency
Input  TT1     : A transitions table
TT2     : Another transitions table
res       : Resolution (in radians/sec)
Output TT      : Transitions table which is a blend of
the transitions from TT1 & TT2.  Transitions
within res frequency from one another are
blended into a single transition with a
summed intensity and weighted frequency
Input TT1 : A transitions table TT2 : Another transitions table res : Resolution ( in radians / sec ) Output TT : Transitions table which is a blend of the transitions from TT1 & TT2 . Transitions within res frequency from one another are blended into a single transition with a summed intensity and weighted frequency
TTable1D sum(const TTable1D& TT1, const TTable1D& TT2, double res)
  {
  int nr1 = TT1.rows();                         
  if(!nr1) return TT2;                          
  int nr2 = TT2.rows();                         
  if(!nr2) return TT1;                          
  vector<int> aflag(nr2);			
  int added=0, newtr=0;                         
  int i1, i2;                                   
  for(i2=0; i2<nr2; i2++)                       
    {
    aflag[i2] = -1;
    for(i1=0, added=0; i1<nr1 && !added; i1++)   to
      if(fabs(TT1.getIm(i1,0)-TT2.getIm(i2,0)) <= res)
        {
        added++;
        aflag[i2] = i1;
        }
    if(!added) newtr++;
    }
  matrix mx(nr1+newtr, 2);
  for(i1=0; i1<nr1; i1++)                       
    {
    mx.put(TT1.get(i1,0), i1,0);
    mx.put(TT1.get(i1,1), i1,1);
    }
  int newrow = nr1;
  int oldrow;
  for(i2=0; i2<nr2; i2++)
    {
    oldrow = aflag[i2];
    if(oldrow >= 0)
      mx.put(mx.get(oldrow,1) + TT2.get(i2,1), oldrow,1);
    else
      {
      mx.put(TT2.get(i2,0), newrow,0);
      mx.put(TT2.get(i2,1), newrow,1);
      newrow++;
      }
    }
  TTable1D TT(mx);
  return TT;
  }
TTable1D sum ( const TTable1D & TT1 , const TTable1D & TT2 , double res ) { int nr1 = TT1 . rows ( ) ; if ( ! nr1 ) return TT2 ; int nr2 = TT2 . rows ( ) ; if ( ! nr2 ) return TT1 ; vector < int > aflag ( nr2 ) ; int added = 0 , newtr = 0 ; int i1 , i2 ; for ( i2 = 0 ; i2 < nr2 ; i2 ++ ) { aflag [ i2 ] = -1 ; for ( i1 = 0 , added = 0 ; i1 < nr1 && ! added ; i1 ++ ) if ( fabs ( TT1 . getIm ( i1 , 0 ) - TT2 . getIm ( i2 , 0 ) ) <= res ) { added ++ ; aflag [ i2 ] = i1 ; } if ( ! added ) newtr ++ ; } matrix mx ( nr1 + newtr , 2 ) ; for ( i1 = 0 ; i1 < nr1 ; i1 ++ ) { mx . put ( TT1 . get ( i1 , 0 ) , i1 , 0 ) ; mx . put ( TT1 . get ( i1 , 1 ) , i1 , 1 ) ; } int newrow = nr1 ; int oldrow ; for ( i2 = 0 ; i2 < nr2 ; i2 ++ ) { oldrow = aflag [ i2 ] ; if ( oldrow >= 0 ) mx . put ( mx . get ( oldrow , 1 ) + TT2 . get ( i2 , 1 ) , oldrow , 1 ) ; else { mx . put ( TT2 . get ( i2 , 0 ) , newrow , 0 ) ; mx . put ( TT2 . get ( i2 , 1 ) , newrow , 1 ) ; newrow ++ ; } } TTable1D TT ( mx ) ; return TT ; }
Input  TT1     : A transitions table
TT2     : Another transitions table
res       : Resolution (in radians/sec)
Output TT      : Transitions table which is a blend of
the transitions from TT1 & TT2.
Input TT1 : A transitions table TT2 : Another transitions table res : Resolution ( in radians / sec ) Output TT : Transitions table which is a blend of the transitions from TT1 & TT2 .
// Rows of original array // 1st array empty, sum is TT2 // Rows of array to add in // 2nd array empty, sum is TT1 // Add flag // Flag if to be added // For array row indexing // Loop rows of array to add // Loop rows of array to add to // Loop rows of array to add // sosi need to set the other parameters to defaults