src/IntRank2/IntDipVec.cc
/* We allow class IntDip to read inidividual interactions from the parameter
   set. This simplifies our task down to dealing with the interaction indexing.
   If a single index is used per interaction this is simple because then the
   interaction index is one in the same as the vector index. If two indices
   (i.e. spin indices) are used per interactions we have a bit more trouble.
   In that case we MUST know the total number of spins we are dealing with in
   order to convert indices i & j into the vector index k. So, first we look
   for the total number of spins set in the parameters.  If found we will allow
   spin indexing and interaction indexing, if not we only allow interaction
   indexing.

	   Input		IDV	: Dipole interaction vector (this)
	   			pset	: A parameter set
	  			idx     : Parameter prefix index
				warn    : Flag for warnings
	   Output		none	: System dipolar interactions are
	  			  	  set from parameters in pset

   We Use Only Parameters With Prefix [#] (unles idx=-1). As such we off this
   prefix from all parameter names prior to looking for the interacitons. 
   This is done before any calls to class IntDip which doesn't use prefixes. */
We allow class IntDip to read inidividual interactions from the parameter
set. This simplifies our task down to dealing with the interaction indexing.
If a single index is used per interaction this is simple because then the
interaction index is one in the same as the vector index. If two indices
are used per interactions we have a bit more trouble.
In that case we MUST know the total number of spins we are dealing with in
order to convert indices i & j into the vector index k. So, first we look
for the total number of spins set in the parameters.  If found we will allow
spin indexing and interaction indexing, if not we only allow interaction
indexing.



We Use Only Parameters With Prefix [#] (unles idx=-1). As such we off this
prefix from all parameter names prior to looking for the interacitons.
This is done before any calls to class IntDip which doesn't use prefixes.
We allow class IntDip to read inidividual interactions from the parameter set . This simplifies our task down to dealing with the interaction indexing . If a single index is used per interaction this is simple because then the interaction index is one in the same as the vector index . If two indices are used per interactions we have a bit more trouble . In that case we MUST know the total number of spins we are dealing with in order to convert indices i & j into the vector index k . So first we look for the total number of spins set in the parameters . If found we will allow spin indexing and interaction indexing if not we only allow interaction indexing . We Use Only Parameters With Prefix [ # ] ( unles idx = - 1 ) . As such we off this prefix from all parameter names prior to looking for the interacitons . This is done before any calls to class IntDip which doesn ' t use prefixes .
bool IntDipVec::setDIV(const ParameterSet& pset, int idx, bool warn)
  {
  clear();                                      
  ParameterSet  subpset;			
  if(idx != -1) subpset = pset.strip(idx);	
  else          subpset = pset;			
  int ns;					
  IntDip D, D0;					
  string udef;					
  if(getNS(pset,idx,ns,0))			
    {						
    int i,j;					
    for(i=0; i<ns-1; i++)			
      {
      for(j=i+1; j<ns; j++)			
        {					
        D = D0;					
        if(!D.read(subpset,i,j, false))		
          {					
          if(udef.length()) udef += string(", ");	
          udef += string("(") + Gdec(i)
               +  string(",") + Gdec(j)
               + string(")");
          }					
        push_back(D);				
        }					
      }
    if(udef.length() && warn)
      {
      if(warn)
        {
        IDVerror(25, 1);
        IDVerror(123, udef, 1);
        }
      return false;
      }
    return true;
    }
    int k = 0;					
    while(D.read(subpset,k))			
      {						
      push_back(D);				
      k++;					
      }
  if(!size()) return false;
  return true;
  }
bool IntDipVec :: setDIV ( const ParameterSet & pset , int idx , bool warn ) { clear ( ) ; ParameterSet subpset ; if ( idx != -1 ) subpset = pset . strip ( idx ) ; else subpset = pset ; int ns ; IntDip D , D0 ; string udef ; if ( getNS ( pset , idx , ns , 0 ) ) { int i , j ; for ( i = 0 ; i < ns - 1 ; i ++ ) { for ( j = i + 1 ; j < ns ; j ++ ) { D = D0 ; if ( ! D . read ( subpset , i , j , false ) ) { if ( udef . length ( ) ) udef += string ( " " ) ; udef += string ( " " ) + Gdec ( i ) + string ( " " ) + Gdec ( j ) + string ( " " ) ; } push_back ( D ) ; } } if ( udef . length ( ) && warn ) { if ( warn ) { IDVerror ( 25 , 1 ) ; IDVerror ( 123 , udef , 1 ) ; } return false ; } return true ; } int k = 0 ; while ( D . read ( subpset , k ) ) { push_back ( D ) ; k ++ ; } if ( ! size ( ) ) return false ; return true ; }
We allow class IntDip to read inidividual interactions from the parameter
set.
We allow class IntDip to read inidividual interactions from the parameter set .
// Remove existing intacts. // Copy parameter set // to glean out those for // the specified prefix index //     Try To Fill Vector Using Spin Pairs When # Of Spins Is Specified //             (Or We Can Figure Out The # Of Spins Specified) // Number of spins to track // Empty dipolar interaction // Undefined interactions // If we know the # of spins // we allow spin indexing //   Two spin indices //   Loop over i spins //   Loop over j spins //   Try and get D(i,j) //     Begin with empty D //     If unsuccessful read, //     store spin indices //     of failed interact. //    Either way, store int //    into the vector (may //    be empty) //      Try To Fill Vector With Either Spin Pair Or Interaction Indices //   Start with 0th D //   If we are able to read it //   then we keep looking //     Put into the vector //     Index to next interaction