small fixes in permutation
This commit is contained in:
@@ -804,16 +804,6 @@ for(int i=0; i<this->size(); ++i) {res[i].perm = (*this)[i].perm * rhs; res[i].
|
||||
return res;
|
||||
}
|
||||
|
||||
template <typename T> template<typename R>
|
||||
PermutationAlgebra<T,R> NRPerm<T>::operator*(const PermutationAlgebra<T,R> &pa) const
|
||||
{
|
||||
PermutationAlgebra<T,R> res(pa.size());
|
||||
for(int i=0; i<pa.size(); ++i) {res[i].perm = *this * pa[i]; res[i].weight= pa[i].weight;}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
template <typename T, typename R>
|
||||
PermutationAlgebra<T,R> PermutationAlgebra<T,R>::operator&(const PermutationAlgebra<T,R> &rhs) const
|
||||
@@ -2201,8 +2191,7 @@ INSTANTIZE(unsigned int)
|
||||
|
||||
|
||||
INSTANTIZE2(int,int)
|
||||
|
||||
|
||||
INSTANTIZE2(int,double)
|
||||
INSTANTIZE2(int,std::complex<double>)
|
||||
|
||||
}//namespace
|
||||
|
||||
@@ -108,6 +108,7 @@ return r;
|
||||
}
|
||||
|
||||
|
||||
|
||||
template <typename T, typename R>
|
||||
class WeightPermutation {
|
||||
public:
|
||||
@@ -115,11 +116,11 @@ public:
|
||||
NRPerm<T> perm;
|
||||
|
||||
int size() const {return perm.size();};
|
||||
bool is_zero() const {return weight==0;}
|
||||
bool is_zero() const {return weight==(R)0;}
|
||||
bool is_scaledidentity() const {return perm.is_identity();}
|
||||
bool is_identity() const {return weight==1 && is_scaledidentity();}
|
||||
bool is_identity() const {return weight==(R)1 && is_scaledidentity();}
|
||||
bool is_plaindata() const {return false;};
|
||||
WeightPermutation() : weight(0) {};
|
||||
WeightPermutation() : weight((R)0) {};
|
||||
explicit WeightPermutation(const NRPerm<T> &p, const R w=1) : weight(w), perm(p) {};
|
||||
void copyonwrite() {perm.copyonwrite();};
|
||||
WeightPermutation operator&(const WeightPermutation &rhs) const {return WeightPermutation(perm&rhs.perm,weight*rhs.weight);};
|
||||
@@ -147,7 +148,7 @@ public:
|
||||
static void copyonwrite(WeightPermutation<T,R>& x) {x.perm.copyonwrite();};
|
||||
typedef typename LA_traits<R>::normtype normtype;
|
||||
typedef R coefficienttype;
|
||||
typedef NRPerm<T> elementtype;
|
||||
typedef R elementtype; //is needed for nrvec::simplify(), not typedef NRPerm<T> elementtype;
|
||||
static inline bool smaller(const WeightPermutation<T,R>& x, const WeightPermutation<T,R>& y) {return x.perm<y.perm;};
|
||||
static inline bool bigger(const WeightPermutation<T,R>& x, const WeightPermutation<T,R>& y) {return x.perm>y.perm;};
|
||||
static R coefficient(const WeightPermutation<T,R>& x){return x.weight;};
|
||||
@@ -448,5 +449,15 @@ for(int i=0; i<rhs.size(); ++i)
|
||||
}
|
||||
}
|
||||
|
||||
//this must be in header as the double template will not be pre-instantiated
|
||||
template <typename T> template<typename R>
|
||||
PermutationAlgebra<T,R> NRPerm<T>::operator*(const PermutationAlgebra<T,R> &pa) const
|
||||
{
|
||||
PermutationAlgebra<T,R> res(pa.size());
|
||||
for(int i=0; i<pa.size(); ++i) {res[i].perm = *this * pa[i].perm; res[i].weight= pa[i].weight;}
|
||||
return res;
|
||||
}
|
||||
|
||||
|
||||
}//namespace
|
||||
#endif
|
||||
|
||||
2
vec.h
2
vec.h
@@ -2096,7 +2096,7 @@ for(int next=1; next<x.size(); ++next)
|
||||
int newsize2=0;
|
||||
for(int next=0; next<newsize; ++next)
|
||||
{
|
||||
if(next==0 && alwayskeepfirst || !(LA_traits<T>::coefficient(x[next])==0 || LA_traits<T>::abscoefficient(x[next]) <thr))
|
||||
if(next==0 && alwayskeepfirst || !(LA_traits<T>::coefficient(x[next])==(typename LA_traits<T>::elementtype)0 || LA_traits<T>::abscoefficient(x[next]) <thr))
|
||||
{
|
||||
if(next!=newsize2) x[newsize2] = x[next];
|
||||
++newsize2;
|
||||
|
||||
Reference in New Issue
Block a user