#include <EvtSpinAmp.hh>
Public Member Functions | |
void | addspin (int twospin) |
bool | allowed (const vector< int > &index) const |
void | assign (const EvtComplex &val) |
const vector< int > & | dims () const |
EvtSpinAmp (const EvtSpinAmp &) | |
EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin, const vector< EvtComplex > &elem) | |
EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin, const EvtComplex &val) | |
EvtSpinAmp (const vector< EvtSpinType::spintype > &twospin) | |
EvtSpinAmp () | |
void | extcont (const EvtSpinAmp &, int, int) |
void | intcont (int, int) |
vector< int > | iterallowedinit () const |
bool | iterate (vector< int > &index) const |
bool | iterateallowed (vector< int > &index) const |
vector< int > | iterinit () const |
EvtSpinAmp | operator * (const EvtSpinAmp &) const |
EvtSpinAmp & | operator *= (const EvtComplex &) |
EvtSpinAmp & | operator *= (const EvtSpinAmp &) |
const EvtComplex & | operator() (int,...) const |
EvtComplex & | operator() (int,...) |
const EvtComplex & | operator() (const vector< int > &) const |
EvtComplex & | operator() (const vector< int > &) |
EvtSpinAmp | operator+ (const EvtSpinAmp &) const |
EvtSpinAmp & | operator+= (const EvtSpinAmp &) |
EvtSpinAmp | operator- (const EvtSpinAmp &) const |
EvtSpinAmp & | operator-= (const EvtSpinAmp &) |
EvtSpinAmp & | operator/= (const EvtComplex &) |
EvtSpinAmp & | operator= (const EvtSpinAmp &) |
int | rank () const |
void | setelem (const vector< EvtComplex > &elem) |
~EvtSpinAmp () | |
Private Member Functions | |
vector< int > | calctwospin (const vector< EvtSpinType::spintype > &type) const |
void | checkindexargs (const vector< int > &index) const |
void | checktwospin (const vector< int > &twospin) const |
int | findtrueindex (const vector< int > &index) const |
Private Attributes | |
vector< EvtComplex > | _elem |
vector< int > | _twospin |
vector< EvtSpinType::spintype > | _type |
Friends | |
EvtSpinAmp | operator * (const EvtSpinAmp &, const EvtComplex &) |
EvtSpinAmp | operator * (const EvtComplex &, const EvtSpinAmp &) |
EvtSpinAmp | operator/ (const EvtSpinAmp &, const EvtComplex &) |
std::ostream & | operator<< (std::ostream &, const EvtSpinAmp &) |
|
00027 {};
|
|
00063 { 00064 int num = 1; 00065 _type = type; 00066 _twospin=calctwospin( type ); 00067 00068 for( int i=0; i<_twospin.size(); ++i ) 00069 num*=_twospin[i]+1; 00070 00071 _elem=vector<EvtComplex>( num ); 00072 }
|
|
00075 { 00076 int num = 1; 00077 _type = type; 00078 _twospin=calctwospin( type ); 00079 00080 for( int i=0; i<_twospin.size(); ++i ) 00081 num*=_twospin[i]+1; 00082 00083 _elem=vector<EvtComplex>( num, val ); 00084 }
|
|
00088 { 00089 int num = 1; 00090 00091 _type = type; 00092 _twospin=calctwospin( type ); 00093 _elem=elem; 00094 00095 for( int i=0; i<_twospin.size(); ++i ) 00096 num*=_twospin[i]+1; 00097 00098 if(_elem.size() != num ) { 00099 report(ERROR,"EvtGen")<<"Wrong number of elements input:" 00100 <<_elem.size()<<" vs. "<<num<<endl; 00101 ::abort(); 00102 } 00103 00104 }
|
|
|
|
00033 {};
|
|
00071 { _twospin.push_back( twospin ); }
|
|
00386 { 00387 if( index.size() != _type.size() ) { 00388 report(ERROR,"EvtGen") 00389 <<"Wrong dimensino index input to allowed."<<endl; 00390 ::abort(); 00391 } 00392 00393 for(int i=0; i<index.size(); ++i) { 00394 switch(_type[i]) { 00395 case EvtSpinType::PHOTON: 00396 if(abs(index[i])!=2) return false; 00397 break; 00398 case EvtSpinType::NEUTRINO: 00399 report(ERROR,"EvtGen") 00400 <<"EvMultibody currently cannot handle neutrinos."<<endl; 00401 ::abort(); 00402 default: 00403 break; 00404 } 00405 } 00406 00407 return true; 00408 }
|
|
|
|
00052 { 00053 vector<int> twospin; 00054 00055 for( int i=0; i<type.size(); ++i ) { 00056 twospin.push_back( EvtSpinType::getSpin2( type[i] ) ); 00057 } 00058 00059 return twospin; 00060 }
|
|
00125 { 00126 if( index.size()==0 ) { 00127 report(ERROR,"EvtGen") << "EvtSpinAmp can't handle no indices" << endl; 00128 ::abort(); 00129 } 00130 00131 if( index.size() != _twospin.size() ) { 00132 report( ERROR, "EvtGen" ) << "Rank of EvtSpinAmp index does not match: " 00133 <<_twospin.size()<<" expected "<<index.size()<<" input."<<endl; 00134 ::abort(); 00135 } 00136 00137 for( int i=0; i<_twospin.size(); ++i ) { 00138 if( _twospin[i]>=abs(index[i]) && _twospin[i]%2==index[i]%2 ) 00139 continue; 00140 report(ERROR,"EvtGen")<<"EvtSpinAmp index out of range" << endl; 00141 report(ERROR,"EvtGen")<<" Index: "; 00142 for(int j=0; j<_twospin.size(); ++j ) 00143 report(ERROR," ")<<_twospin[j]; 00144 00145 report(ERROR, " ")<<endl<<" Index: "; 00146 for(int j=0; j<index.size(); ++j ) 00147 report(ERROR," ")<<index[j]; 00148 report(ERROR, " ")<<endl; 00149 ::abort(); 00150 } 00151 }
|
|
00114 { 00115 if( _twospin == twospin ) 00116 return; 00117 00118 report( ERROR, "EvtGen" ) 00119 <<"Dimension or order of tensors being operated on does not match" 00120 <<endl; 00121 ::abort(); 00122 }
|
|
00067 { return _twospin; }
|
|
00489 { 00490 EvtSpinAmp ret = (*this)*cont; 00491 ret.intcont( a, rank()+b ); 00492 00493 *this=ret; 00494 }
|
|
00154 { 00155 int trueindex = 0; 00156 00157 for( int i = index.size()-1; i>0; --i ) { 00158 trueindex += (index[i]+_twospin[i])/2; 00159 trueindex *= _twospin[i-1]+1; 00160 } 00161 00162 trueindex += (index[0]+_twospin[0])/2; 00163 00164 return trueindex; 00165 }
|
|
00431 { 00432 int newrank=rank()-2; 00433 if(newrank<=0) { 00434 report(ERROR,"EvtGen")<<"EvtSpinAmp can't handle no indices" << endl; 00435 ::abort(); 00436 } 00437 00438 if(_twospin[a]!=_twospin[b]) { 00439 report(ERROR,"EvtGen") 00440 <<"Contaction called on indices of different dimension" 00441 <<endl; 00442 report(ERROR,"EvtGen") 00443 <<"Called on "<<_twospin[a]<<" and "<<_twospin[b] 00444 <<endl; 00445 ::abort(); 00446 } 00447 00448 vector<int> newtwospin( newrank ); 00449 vector<EvtSpinType::spintype> newtype( newrank ); 00450 00451 for( int i=0, j=0; i<_twospin.size(); ++i ){ 00452 if(i==a || i==b) continue; 00453 00454 newtwospin[j] = _twospin[i]; 00455 newtype[j] = _type[i]; 00456 ++j; 00457 } 00458 00459 EvtSpinAmp newamp( newtype ); 00460 vector<int> index( rank() ), newindex = newamp.iterinit(); 00461 00462 for( int i=0; i<newrank; ++i ) 00463 newindex[i] = -newtwospin[i]; 00464 00465 while(true) { 00466 00467 for( int i=0, j=0; i<rank(); ++i ) { 00468 if(i==a || i==b) continue; 00469 index[i]=newindex[j]; 00470 ++j; 00471 } 00472 00473 index[b]=index[a]=-_twospin[a]; 00474 newamp(newindex) = (*this)(index); 00475 for( int i=-_twospin[a]+2; i<=_twospin[a]; i+=2 ) { 00476 index[b]=index[a]=i; 00477 newamp(newindex) += (*this)(index); 00478 } 00479 00480 if(!newamp.iterate(newindex)) break; 00481 } 00482 00483 *this=newamp; 00484 }
|
|
00421 { 00422 vector<int> init = iterinit(); 00423 while(!allowed(init)) { 00424 iterate(init); 00425 } 00426 00427 return init; 00428 }
|
|
00369 { 00370 int last = _twospin.size() - 1; 00371 00372 index[0]+=2; 00373 for( int j=0; j<last; ++j ) { 00374 if( index[j] > _twospin[j] ) { 00375 index[j] = -_twospin[j]; 00376 index[j+1]+=2; 00377 } 00378 } 00379 00380 return abs(index[last])<=_twospin[last]; 00381 }
|
|
00411 { 00412 while(true) { 00413 if(!iterate( index )) 00414 return false; 00415 if(allowed( index )) 00416 return true; 00417 } 00418 }
|
|
00359 { 00360 vector<int> init( _twospin.size() ); 00361 00362 for( int i=0; i<_twospin.size(); ++i ) 00363 init[i]=-_twospin[i]; 00364 00365 return init; 00366 }
|
|
00300 { 00301 vector<int> index(rank()+amp2.rank()); 00302 vector<int> index1(rank()), index2(amp2.rank()); 00303 EvtSpinAmp amp; 00304 00305 amp._twospin=_twospin; 00306 amp._type=_type; 00307 00308 for( int i=0; i<amp2._twospin.size(); ++i ) { 00309 amp._twospin.push_back( amp2._twospin[i] ); 00310 amp._type.push_back( amp2._type[i] ); 00311 } 00312 00313 amp._elem = vector<EvtComplex>( _elem.size() * amp2._elem.size() ); 00314 00315 for( int i=0; i<index1.size(); ++i ) 00316 index[i]=index1[i]=-_twospin[i]; 00317 00318 for( int i=0; i<index2.size(); ++i ) 00319 index[i+rank()]=index2[i]=-amp2._twospin[i]; 00320 00321 while(true) { 00322 amp( index ) = (*this)( index1 )*amp2( index2 ); 00323 if(!amp.iterate( index )) break; 00324 00325 for( int i=0; i<index1.size(); ++i ) 00326 index1[i]=index[i]; 00327 00328 for( int i=0; i<index2.size(); ++i ) 00329 index2[i]=index[i+rank()]; 00330 } 00331 00332 return amp; 00333 }
|
|
00343 { 00344 for( int i=0; i<_elem.size(); ++i ) 00345 _elem[i] *= real; 00346 00347 return *this; 00348 }
|
|
00336 { 00337 EvtSpinAmp ret = (*this)*cont; 00338 *this=ret; 00339 return *this; 00340 }
|
|
00230 { 00231 vector<int> index( _twospin.size() ); 00232 va_list ap; 00233 00234 va_start(ap, i); 00235 00236 index[0]=i; 00237 for(int n=1; n<_twospin.size(); ++n ) 00238 index[n]=va_arg( ap, int ); 00239 00240 va_end(ap); 00241 00242 return (*this)( index ); 00243 }
|
|
00214 { 00215 va_list ap; 00216 vector<int> index( _twospin.size() ); 00217 00218 va_start(ap, i); 00219 00220 index[0]=i; 00221 for(int n=1; n<_twospin.size(); ++n ) 00222 index[n]=va_arg( ap, int ); 00223 00224 va_end(ap); 00225 00226 return (*this)( index ); 00227 }
|
|
00191 { 00192 checkindexargs( index ); 00193 00194 int trueindex = findtrueindex(index); 00195 if(trueindex >= _elem.size()) { 00196 report(ERROR,"EvtGen")<<"indexing error "<<trueindex<<" "<<_elem.size()<<endl; 00197 for(int i=0; i<_twospin.size(); ++i) { 00198 report(ERROR,"")<<_twospin[i]<<" "; 00199 } 00200 report(ERROR,"")<<endl; 00201 00202 for(int i=0; i<index.size(); ++i) { 00203 report(ERROR,"")<<index[i]<<" "; 00204 } 00205 report(ERROR,"")<<endl; 00206 00207 ::abort(); 00208 } 00209 00210 return _elem[trueindex]; 00211 }
|
|
00168 { 00169 checkindexargs( index ); 00170 00171 int trueindex = findtrueindex(index); 00172 if(trueindex >= _elem.size()) { 00173 report(ERROR,"EvtGen")<<"indexing error "<<trueindex<<" "<<_elem.size()<<endl; 00174 for(int i=0; i<_twospin.size(); ++i) { 00175 report(ERROR,"")<<_twospin[i]<<" "; 00176 } 00177 report(ERROR,"")<<endl; 00178 00179 for(int i=0; i<index.size(); ++i) { 00180 report(ERROR,"")<<index[i]<<" "; 00181 } 00182 report(ERROR,"")<<endl; 00183 00184 ::abort(); 00185 } 00186 00187 return _elem[trueindex]; 00188 }
|
|
00255 { 00256 checktwospin( cont._twospin ); 00257 00258 EvtSpinAmp ret( cont ); 00259 for( int i=0; i<ret._elem.size(); ++i ) { 00260 ret._elem[i]+=_elem[i]; 00261 } 00262 00263 return ret; 00264 }
|
|
00268 { 00269 checktwospin( cont._twospin ); 00270 00271 for( int i=0; i<_elem.size(); ++i ) 00272 _elem[i]+=cont._elem[i]; 00273 00274 return *this; 00275 }
|
|
00278 { 00279 checktwospin( cont._twospin ); 00280 00281 EvtSpinAmp ret( *this ); 00282 for( int i=0; i<ret._elem.size(); ++i ) 00283 ret._elem[i]-=cont._elem[i]; 00284 00285 return ret; 00286 }
|
|
00289 { 00290 checktwospin( cont._twospin ); 00291 00292 for( int i=0; i<_elem.size(); ++i ) 00293 _elem[i]-=cont._elem[i]; 00294 00295 return *this; 00296 }
|
|
00351 { 00352 for( int i=0; i<_elem.size(); ++i ) 00353 _elem[i] /= real; 00354 00355 return *this; 00356 }
|
|
00246 { 00247 _twospin=cont._twospin; 00248 _elem=cont._elem; 00249 _type=cont._type; 00250 00251 return *this; 00252 }
|
|
00064 { return _twospin.size(); }
|
|
00072 { _elem = elem; }
|
|
00036 { 00037 return real*cont; 00038 }
|
|
00025 { 00026 EvtSpinAmp ret( cont ); 00027 00028 for( int i=0; i<ret._elem.size(); ++i ) { 00029 ret._elem[i] *= real; 00030 } 00031 00032 return ret; 00033 }
|
|
00041 { 00042 EvtSpinAmp ret( cont ); 00043 00044 for( int i=0; i<ret._elem.size(); ++i ) { 00045 ret._elem[i] /= real; 00046 } 00047 00048 return ret; 00049 }
|
|
00009 { 00010 vector<int> index = amp.iterinit(); 00011 00012 os << ":"; 00013 do { 00014 os<<"<"; 00015 for(int i=0; i<index.size()-1; ++i) { 00016 os<<index[i]; 00017 } 00018 os<<index[index.size()-1]<<">"<<amp(index)<<":"; 00019 } while( amp.iterate( index ) ); 00020 00021 return os; 00022 }
|
|
|
|
|
|
|