From 6281449dbbf7db88417526902c2531d47c566d0c Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Sat, 15 Nov 2025 18:32:56 +0100 Subject: [PATCH] identity() for permutationalgebra --- permutation.h | 6 ++++++ 1 file changed, 6 insertions(+) diff --git a/permutation.h b/permutation.h index 26914ee..2fa93df 100644 --- a/permutation.h +++ b/permutation.h @@ -56,8 +56,10 @@ public: explicit NRPerm(const CyclePerm &rhs, const int n=0); //specific operations + void resize(int n) {NRVec_from1::resize(n);}; int size() const {return NRVec_from1::size();}; void identity(); + void identity(int n) {resize(n); identity();}; bool is_valid() const; //is it really a permutation bool is_identity() const; CompressedPartition cycles() const {return CyclePerm(*this).cycles(size());}; @@ -120,6 +122,8 @@ public: bool is_scaledidentity() const {return perm.is_identity();} bool is_identity() const {return weight==(R)1 && is_scaledidentity();} bool is_plaindata() const {return false;}; + void identity() {weight=(R)1; perm.identity();}; + void identity(int n) {weight=(R)1; perm.resize(n); perm.identity();}; WeightPermutation() : weight((R)0) {}; explicit WeightPermutation(const NRPerm &p, const R w=1) : weight(w), perm(p) {}; void copyonwrite() {perm.copyonwrite();}; @@ -186,6 +190,7 @@ public: template PermutationAlgebra(const PermutationAlgebra &rhs) : NRVec >(rhs.size()) {for(int i=0; i >::size();}; + void resize(int n) { NRVec >::resize(n);}; void copyonwrite() {NRVec >::copyonwrite();}; int sort(int direction = 0, int from = 0, int to = -1, int *permut = NULL, bool stable=false) {return NRVec >::sort(direction,from, to,permut,stable);}; @@ -207,6 +212,7 @@ public: bool is_zero() const {return size()==0;}; //assume it was simplified bool is_scaled_identity() const {return size()==1 && (*this)[0].is_scaledidentity();}; //assume it was simplified bool is_identity() const {return size()==1 && (*this)[0].is_identity();}; //assume it was simplified + void identity(int n) {resize(1); (*this)[0].identity(n);}; };