src/Bloch/BlochR.cc
/* These allow users to set up an R matrix for any number of components.

	   Input	    T1s : Longitudinal relaxation rate/time
	        	    T2s : Transverse relaxation rate/time
                            rate: Flag if values are rates or times
	   Output	      R	: 3Nx2N Bloch relaxation matrix where N
				  is the size of vectors T1s and T2s
	   Note			: T1 & T2 values in seconds
	   Note			: R is output in 1/sec
	   Note			: Zero or negative relaxation
	  			  rates result in a zero R                   */
These allow users to set up an R matrix for any number of components.
These allow users to set up an R matrix for any number of components .
BlochMx BlochR(std::vector<double> T1s, std::vector<double> T2s, bool rate)
  {
  int nv = T1s.size();
  matrix R(nv, nv, 0.0, d_matrix_type);
  if(rate)
    {
    for(int i=0; i<nv; i++)
      {
      R.put(fabs(T2s[i]), 3*i,   3*i);		
      R.put(fabs(T2s[i]), 3*i+1, 3*i+1);	
      R.put(fabs(T1s[i]), 3*i+2, 3*i+2);	
      }
    }
  else
    {
    double r2, r1, t2, t1;
    for(int i=0; i<nv; i++)
      {
      t2 = fabs(T2s[i]);
      t1 = fabs(T1s[i]);
      if(t1 < 1.e-13) r1 = 0; 
      else            r1 = 1.0/t1; 
      if(t2 < 1.e-13) r2 = 0; 
      else            r2 = 1.0/t2; 
      R.put(r2, 3*i,   3*i);		
      R.put(r2, 3*i+1, 3*i+1);		
      R.put(r1, 3*i+2, 3*i+2);		
      }
    }
  return BlochMx(R);
  }
BlochMx BlochR ( std :: vector < double > T1s , std :: vector < double > T2s , bool rate ) { int nv = T1s . size ( ) ; matrix R ( nv , nv , 0.0 , d_matrix_type ) ; if ( rate ) { for ( int i = 0 ; i < nv ; i ++ ) { R . put ( fabs ( T2s [ i ] ) , 3 * i , 3 * i ) ; R . put ( fabs ( T2s [ i ] ) , 3 * i + 1 , 3 * i + 1 ) ; R . put ( fabs ( T1s [ i ] ) , 3 * i + 2 , 3 * i + 2 ) ; } } else { double r2 , r1 , t2 , t1 ; for ( int i = 0 ; i < nv ; i ++ ) { t2 = fabs ( T2s [ i ] ) ; t1 = fabs ( T1s [ i ] ) ; if ( t1 < 1.e-13 ) r1 = 0 ; else r1 = 1.0 / t1 ; if ( t2 < 1.e-13 ) r2 = 0 ; else r2 = 1.0 / t2 ; R . put ( r2 , 3 * i , 3 * i ) ; R . put ( r2 , 3 * i + 1 , 3 * i + 1 ) ; R . put ( r1 , 3 * i + 2 , 3 * i + 2 ) ; } } return BlochMx ( R ) ; }
These allow users to set up an R matrix for any number of components.
These allow users to set up an R matrix for any number of components .
// Set <1|Ri|1> to R2i // Set <2|Ri|2> to R2i // Set <3|Ri|3> to R1i // Set <1|Ri|1> to 1/T2i // Set <2|Ri|2> to 1/T2i // Set <3|Ri|3> to 1/T1i