From f8b2ee6e1a3cccc4fd50dcb8af30554c7b92efc8 Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Wed, 8 Nov 2023 16:56:57 +0100 Subject: [PATCH] multiplication of permutations in different notation --- permutation.cc | 16 ++++++++++++++++ permutation.h | 2 ++ 2 files changed, 18 insertions(+) diff --git a/permutation.cc b/permutation.cc index e085d8c..11e7229 100644 --- a/permutation.cc +++ b/permutation.cc @@ -642,6 +642,22 @@ NRPerm rr=pp*qq; return CyclePerm(rr); } + +//mixed type multiplications +template +NRPerm NRPerm::operator*(const CyclePerm &r) const +{ +NRPerm rr(r,this->size()); +return *this * rr; +} + +template +NRPerm CyclePerm::operator*(const NRPerm &r) const +{ +NRPerm tt(*this,r.size()); +return tt*r; +} + template void CyclePerm::simplify(bool keep1) { diff --git a/permutation.h b/permutation.h index d8bcf86..5b6583b 100644 --- a/permutation.h +++ b/permutation.h @@ -56,6 +56,7 @@ public: NRPerm inverse() const; NRPerm reverse() const; //backward order NRPerm operator*(const NRPerm q) const; //q is rhs and applied first, this applied second + NRPerm operator*(const CyclePerm &r) const; NRPerm conjugate_by(const NRPerm q) const; //q^-1 p q int parity() const; void randomize(void); //uniformly random by Fisher-Yates shuffle @@ -92,6 +93,7 @@ public: CompressedPartition cycles(const T n) const; void readfrom(const std::string &line); CyclePerm operator*(const CyclePerm q) const; //q is rhs and applied first, this applied second + NRPerm operator*(const NRPerm &r) const; PERM_RANK_TYPE order() const; //lcm of cycle lengths bool operator==(const CyclePerm &rhs) const {return NRPerm(*this) == NRPerm(rhs);}; //cycle representation is not unique, cannot inherit operator== from NRVec void simplify(bool keep1=false); //remove cycles of size 0 or 1