small fixes in permutation

This commit is contained in:
2025-11-14 16:15:58 +01:00
parent c7c21ee1a8
commit 89cc0c5b1e
3 changed files with 18 additions and 18 deletions

View File

@@ -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

View File

@@ -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

4
vec.h
View File

@@ -133,7 +133,7 @@ public:
//inline NRVec(const T &a, const int n);
inline NRVec(const T &a, const int n, const GPUID loc = undefined);
//! inlined constructor creating vector froman array
//! inlined constructor creating vector from an array
template<int SIZE> inline NRVec(const T (&a)[SIZE]);
//! inlined constructor creating vector of given size filled with data located at given memory location
@@ -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;