From 2cb5258cd03fb1200cb086affe4ed70678e2a04a Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Thu, 18 Jan 2024 17:56:59 +0100 Subject: [PATCH] fixed permutation matrices --- mat.cc | 31 +++++++++++++++++++++++++------ mat.h | 3 ++- t.cc | 20 +++++++++++++++++--- 3 files changed, 44 insertions(+), 10 deletions(-) diff --git a/mat.cc b/mat.cc index 469246e..78d0750 100644 --- a/mat.cc +++ b/mat.cc @@ -1834,6 +1834,25 @@ NRMat >::dot(const NRMat > &rhs) const return ret; } + +template<> +const NRMat NRMat::operator*(const NRMat &rhs) const { +#ifdef DEBUG + if(mm != rhs.nn) laerror("incompatible matrices in NRMat::operator*(const NRMat&)"); + if(mm<=0 ||rhs.mm <= 0) laerror("illegal matrix dimension in gemm"); +#endif + NOT_GPU(rhs); + NOT_GPU(*this); + NRMat result(nn, rhs.mm); + result.clear(); + for(int i=0;i NRMat::NRMat(const NRPerm &p, const bool direction, const bool parity) { int n=p.size(); -resize(n,n); +nn=mm=0; count=0; v=0; resize(n,n); clear(); T alpha= parity? p.parity():1; axpy(alpha,p,direction); @@ -3177,18 +3196,18 @@ template NRMat::NRMat(const WeightPermutation &wp, const bool direction) { int n=wp.size(); -resize(n,n); +nn=mm=0; count=0; v=0; resize(n,n); clear(); axpy(wp.weight,wp.perm,direction); } template -NRMat::NRMat(const PermutationAlgebra &ap, const bool direction) +NRMat::NRMat(const PermutationAlgebra &ap, const bool direction , int nforce) { int na= ap.size(); -if(na<=0) laerror("cannot deduce matrix size from empty PermutationAlgebra"); -int n=ap[0].size(); -resize(n,n); +if(na<=0 && nforce<=0) laerror("cannot deduce matrix size from empty PermutationAlgebra"); +int n= nforce>0?nforce:ap[0].size(); +nn=mm=0; count=0; v=0; resize(n,n); clear(); for(int i=0; i &p, const bool direction); explicit NRMat(const NRPerm &p, const bool direction, const bool parity=false); //permutation matrix explicit NRMat(const WeightPermutation &p, const bool direction); - explicit NRMat(const PermutationAlgebra &p, const bool direction); + explicit NRMat(const PermutationAlgebra &p, const bool direction, const int nforce=0); //note that one cannot represent e.g. young projectors in this way, since the representation of S(n) by permutation matrices is reducible just to two irreps [n] and [n-1,1] /***************************************************************************//** @@ -1167,6 +1167,7 @@ void NRMat::copyonwrite(bool detachonly) { * @see count, NRMat::copyonwrite(), NRMat::operator|=() * @return reference to the newly copied matrix ******************************************************************************/ +//NOTE it must not be used in constructors when the data were not initialized yet template void NRMat::resize(int n, int m) { #ifdef DEBUG diff --git a/t.cc b/t.cc index f8a79ec..f101b09 100644 --- a/t.cc +++ b/t.cc @@ -91,6 +91,7 @@ cout< > allyoung; +static NRVec >allyoungmat; static NRVec allyoung_irrep; int current_irrep; int allyoung_index; @@ -101,6 +102,8 @@ cout < r=allyoung[i]*allyoung[j]; //cout <<"Young "< r=allyoung[i]*allyoung[j]; + NRMat rm(r,false,n); + NRMat rm2 = allyoungmat[i]*allyoungmat[j]; + cout <<"Product of Young "<