37 for (
size_t i = 0; i < index.size() - 1; ++i ) {
40 os << index[index.size() - 1] <<
">" << amp( index ) <<
":";
41 }
while ( amp.
iterate( index ) );
50 for (
size_t i = 0; i < ret.
_elem.size(); ++i ) {
66 for (
size_t i = 0; i < ret.
_elem.size(); ++i ) {
74 const vector<EvtSpinType::spintype>& type )
const 76 vector<unsigned int> twospin;
78 for (
size_t i = 0; i < type.size(); ++i ) {
91 for (
size_t i = 0; i <
_twospin.size(); ++i )
94 _elem = vector<EvtComplex>( num );
104 for (
size_t i = 0; i <
_twospin.size(); ++i )
107 _elem = vector<EvtComplex>( num, val );
111 const vector<EvtComplex>& elem )
119 for (
size_t i = 0; i <
_twospin.size(); ++i ) {
123 if (
_elem.size() != num ) {
125 <<
"Wrong number of elements input:" <<
_elem.size() <<
" vs. " 144 <<
"Dimension or order of tensors being operated on does not match" 151 if ( index.size() == 0 ) {
153 <<
"EvtSpinAmp can't handle no indices" << endl;
157 if ( index.size() !=
_twospin.size() ) {
159 <<
"Rank of EvtSpinAmp index does not match: " <<
_twospin.size()
160 <<
" expected " << index.size() <<
" input." << endl;
164 for (
size_t i = 0; i <
_twospin.size(); ++i ) {
165 if ( static_cast<int>(
_twospin[i] ) >=
abs( index[i] ) &&
166 static_cast<int>(
_twospin[i] ) % 2 == index[i] % 2 )
169 <<
"EvtSpinAmp index out of range" << endl;
171 for (
size_t j = 0; j <
_twospin.size(); ++j )
175 for (
size_t j = 0; j < index.size(); ++j )
186 for (
size_t i = index.size() - 1; i > 0; --i ) {
187 trueindex += ( index[i] +
_twospin[i] ) / 2;
191 trueindex += ( index[0] +
_twospin[0] ) / 2;
201 if ( trueindex >=
_elem.size() ) {
203 <<
"indexing error " << trueindex <<
" " <<
_elem.size() << endl;
204 for (
size_t i = 0; i <
_twospin.size(); ++i ) {
209 for (
size_t i = 0; i < index.size(); ++i ) {
217 return _elem[trueindex];
225 if ( trueindex >=
_elem.size() ) {
227 <<
"indexing error " << trueindex <<
" " <<
_elem.size() << endl;
228 for (
size_t i = 0; i <
_twospin.size(); ++i ) {
233 for (
size_t i = 0; i < index.size(); ++i ) {
241 return _elem[trueindex];
247 vector<int> index(
_twospin.size() );
252 for (
size_t n = 1; n <
_twospin.size(); ++n )
253 index[n] = va_arg( ap,
int );
257 return ( *
this )( index );
262 vector<int> index(
_twospin.size() );
268 for (
size_t n = 1; n <
_twospin.size(); ++n )
269 index[n] = va_arg( ap,
int );
273 return ( *
this )( index );
290 for (
size_t i = 0; i < ret.
_elem.size(); ++i ) {
301 for (
size_t i = 0; i <
_elem.size(); ++i )
312 for (
size_t i = 0; i < ret.
_elem.size(); ++i )
322 for (
size_t i = 0; i <
_elem.size(); ++i )
331 vector<int> index(
rank() + amp2.
rank() );
332 vector<int> index1(
rank() ), index2( amp2.
rank() );
338 for (
size_t i = 0; i < amp2.
_twospin.size(); ++i ) {
339 amp._twospin.push_back( amp2.
_twospin[i] );
340 amp._type.push_back( amp2.
_type[i] );
343 amp._elem = vector<EvtComplex>(
_elem.size() * amp2.
_elem.size() );
345 for (
size_t i = 0; i < index1.size(); ++i )
346 index[i] = index1[i] = -
_twospin[i];
348 for (
size_t i = 0; i < index2.size(); ++i )
352 amp( index ) = ( *this )(index1)*amp2( index2 );
353 if ( !amp.iterate( index ) )
356 for (
size_t i = 0; i < index1.size(); ++i )
357 index1[i] = index[i];
359 for (
size_t i = 0; i < index2.size(); ++i )
360 index2[i] = index[i +
rank()];
375 for (
size_t i = 0; i <
_elem.size(); ++i )
383 for (
size_t i = 0; i <
_elem.size(); ++i )
391 vector<int> init(
_twospin.size() );
393 for (
size_t i = 0; i <
_twospin.size(); ++i )
404 for (
size_t j = 0; static_cast<int>( j ) < last; ++j ) {
405 if ( index[j] > static_cast<int>(
_twospin[j] ) ) {
411 return (
abs( index[last] ) ) <= ( (
int)
_twospin[last] );
418 if ( index.size() !=
_type.size() ) {
420 <<
"Wrong dimensino index input to allowed." << endl;
424 for (
size_t i = 0; i < index.size(); ++i ) {
425 switch (
_type[i] ) {
427 if (
abs( index[i] ) != 2 )
432 <<
"EvMultibody currently cannot handle neutrinos." << endl;
466 <<
"EvtSpinAmp can't handle no indices" << endl;
470 size_t newrank =
rank() - 2;
474 <<
"Contaction called on indices of different dimension" << endl;
480 vector<int> newtwospin( newrank );
481 vector<EvtSpinType::spintype> newtype( newrank );
483 for (
size_t i = 0, j = 0; i <
_twospin.size(); ++i ) {
484 if ( i == a || i == b )
488 newtype[j] =
_type[i];
493 vector<int> index(
rank() ), newindex = newamp.
iterinit();
495 for (
size_t i = 0; i < newrank; ++i )
496 newindex[i] = -newtwospin[i];
499 for (
size_t i = 0, j = 0; i <
rank(); ++i ) {
500 if ( i == a || i == b )
502 index[i] = newindex[j];
507 newamp( newindex ) = ( *this )( index );
509 index[b] = index[a] = i;
510 newamp( newindex ) += ( *this )( index );
513 if ( !newamp.
iterate( newindex ) )
EvtSpinAmp operator/(const EvtSpinAmp &cont, const EvtComplex &real)
EvtSpinAmp & operator/=(const EvtComplex &)
bool iterateallowed(vector< int > &index) const
EvtComplex & operator()(const vector< int > &)
void extcont(const EvtSpinAmp &, int, int)
void checktwospin(const vector< unsigned int > &twospin) const
vector< int > iterallowedinit() const
std::ostream & EvtGenReport(EvtGenSeverity severity, const char *facility=0)
void checkindexargs(const vector< int > &index) const
EvtComplex cont(const EvtTensor4C &t1, const EvtTensor4C &t2)
EvtSpinAmp & operator+=(const EvtSpinAmp &)
int findtrueindex(const vector< int > &index) const
EvtSpinAmp & operator=(const EvtSpinAmp &)
vector< unsigned int > _twospin
std::ostream & operator<<(std::ostream &os, const EvtSpinAmp &)
vector< unsigned int > calctwospin(const vector< EvtSpinType::spintype > &type) const
bool allowed(const vector< int > &index) const
EvtSpinAmp & operator-=(const EvtSpinAmp &)
vector< int > iterinit() const
EvtSpinAmp operator *(const EvtComplex &real, const EvtSpinAmp &cont)
double abs(const EvtComplex &c)
EvtSpinAmp & operator *=(const EvtSpinAmp &)
bool iterate(vector< int > &index) const
static int getSpin2(spintype stype)
friend EvtSpinAmp operator *(const EvtComplex &, const EvtSpinAmp &)
EvtSpinAmp operator+(const EvtSpinAmp &) const
EvtSpinAmp operator-(const EvtSpinAmp &) const
void intcont(size_t, size_t)
double real(const EvtComplex &c)
vector< EvtSpinType::spintype > _type
vector< EvtComplex > _elem