From ce4401ac6c3e0d27aee0b461e1801b0297e48fdb Mon Sep 17 00:00:00 2001 From: j9263178 Date: Fri, 1 Dec 2023 14:43:00 +0800 Subject: [PATCH 1/4] change zn reverse rule --- src/Symmetry.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/Symmetry.cpp b/src/Symmetry.cpp index 8e885169..5dadfe9b 100644 --- a/src/Symmetry.cpp +++ b/src/Symmetry.cpp @@ -164,7 +164,7 @@ namespace cytnx { } void cytnx::ZnSymmetry::reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in) { // out = -in<0?-in+this->n:-in; - out = in * -1; + out = in; } void cytnx::ZnSymmetry::print_info() const { From 1da566810bd925f899f08bf72420a75563d7ead7 Mon Sep 17 00:00:00 2001 From: j9263178 Date: Fri, 1 Dec 2023 15:06:31 +0800 Subject: [PATCH 2/4] change zn combine rule --- src/Symmetry.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Symmetry.cpp b/src/Symmetry.cpp index 5dadfe9b..1d03d8af 100644 --- a/src/Symmetry.cpp +++ b/src/Symmetry.cpp @@ -150,7 +150,7 @@ namespace cytnx { #pragma omp parallel for schedule(dynamic) #endif for (cytnx_uint64 i = 0; i < out.size(); i++) { - out[i] = (inL[cytnx_uint64(i / inR.size())] + inR[i % inR.size()]) % (this->n); + out[i] = abs((inL[cytnx_uint64(i / inR.size())] + inR[i % inR.size()]) % (this->n)); } } void cytnx::ZnSymmetry::combine_rule_(cytnx_int64 &out, const cytnx_int64 &inL, @@ -160,11 +160,11 @@ namespace cytnx { if (is_reverse) this->reverse_rule_(out, (inL + inR) % (this->n)); else - out = (inL + inR) % (this->n); + out = abs((inL + inR) % (this->n)); } void cytnx::ZnSymmetry::reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in) { // out = -in<0?-in+this->n:-in; - out = in; + out = in * -1; } void cytnx::ZnSymmetry::print_info() const { From ca5eaff7b84e744ef2aa2c1866a430e4727902b4 Mon Sep 17 00:00:00 2001 From: j9263178 Date: Fri, 1 Dec 2023 17:20:44 +0800 Subject: [PATCH 3/4] update combine rule --- src/Symmetry.cpp | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/Symmetry.cpp b/src/Symmetry.cpp index 1d03d8af..d66f46b0 100644 --- a/src/Symmetry.cpp +++ b/src/Symmetry.cpp @@ -150,17 +150,20 @@ namespace cytnx { #pragma omp parallel for schedule(dynamic) #endif for (cytnx_uint64 i = 0; i < out.size(); i++) { - out[i] = abs((inL[cytnx_uint64(i / inR.size())] + inR[i % inR.size()]) % (this->n)); + out[i] = (inL[cytnx_uint64(i / inR.size())] + inR[i % inR.size()]) % (this->n); + if (out[i] < 0) out[i] += this->n; } } void cytnx::ZnSymmetry::combine_rule_(cytnx_int64 &out, const cytnx_int64 &inL, const cytnx_int64 &inR, const bool &is_reverse) { out = (inL + inR) % (this->n); - if (is_reverse) + if (is_reverse) { this->reverse_rule_(out, (inL + inR) % (this->n)); - else - out = abs((inL + inR) % (this->n)); + } else { + out = (inL + inR) % (this->n); + if (out < 0) out += this->n; + } } void cytnx::ZnSymmetry::reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in) { // out = -in<0?-in+this->n:-in; From 47cc3d1060758b77c5679cbd0e84811551fa0777 Mon Sep 17 00:00:00 2001 From: j9263178 Date: Fri, 1 Dec 2023 17:50:58 +0800 Subject: [PATCH 4/4] update inverse rule --- src/Symmetry.cpp | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/src/Symmetry.cpp b/src/Symmetry.cpp index d66f46b0..d88d1cc2 100644 --- a/src/Symmetry.cpp +++ b/src/Symmetry.cpp @@ -151,23 +151,18 @@ namespace cytnx { #endif for (cytnx_uint64 i = 0; i < out.size(); i++) { out[i] = (inL[cytnx_uint64(i / inR.size())] + inR[i % inR.size()]) % (this->n); - if (out[i] < 0) out[i] += this->n; } } void cytnx::ZnSymmetry::combine_rule_(cytnx_int64 &out, const cytnx_int64 &inL, const cytnx_int64 &inR, const bool &is_reverse) { - out = (inL + inR) % (this->n); - - if (is_reverse) { + if (is_reverse) this->reverse_rule_(out, (inL + inR) % (this->n)); - } else { + else out = (inL + inR) % (this->n); - if (out < 0) out += this->n; - } } void cytnx::ZnSymmetry::reverse_rule_(cytnx_int64 &out, const cytnx_int64 &in) { // out = -in<0?-in+this->n:-in; - out = in * -1; + out = -in + this->n; } void cytnx::ZnSymmetry::print_info() const {