From 4e2ee8a14e89f2481ca39df3716b08ff2064cd53 Mon Sep 17 00:00:00 2001 From: Jiri Pittner Date: Fri, 28 Oct 2022 19:59:33 +0200 Subject: [PATCH] implementation of NRVec::permuted moved to permutation.h --- permutation.h | 26 ++++++++++++++++++++++++++ vec.cc | 25 ------------------------- 2 files changed, 26 insertions(+), 25 deletions(-) diff --git a/permutation.h b/permutation.h index 52f76ad..326e755 100644 --- a/permutation.h +++ b/permutation.h @@ -240,5 +240,31 @@ template extern std::ostream & operator<<(std::ostream &s, const Sn_characters &c); +template +const NRVec NRVec::permuted(const NRPerm &p, const bool inverse) const +{ +#ifdef DEBUG +if(!p.is_valid()) laerror("invalid permutation of vector"); +#endif +int n=p.size(); +if(n!=(*this).size()) laerror("incompatible permutation and vector"); +#ifdef CUDALA + if(this->getlocation() != cpu || p.getlocation() != cpu ) laerror("permutations can be done only in CPU memory"); +#endif +NRVec r(n); +if(inverse) for(int i=1; i<=n; ++i) r[i-1] = v[p[i]-1]; +else for(int i=1; i<=n; ++i) r[p[i]-1] = v[i-1]; +return r; +} + +template +void NRVec::permuteme(const NRPerm &p, bool inverse) +{ +NRVec tmp=permuted(p,inverse); +for(int i=0; i > complexify(const NRVec &rhs) { #endif return r; } - -template -const NRVec NRVec::permuted(const NRPerm &p, const bool inverse) const -{ -#ifdef DEBUG -if(!p.is_valid()) laerror("invalid permutation of vector"); -#endif -int n=p.size(); -if(n!=(*this).size()) laerror("incompatible permutation and vector"); -#ifdef CUDALA - if(this->getlocation() != cpu || p.getlocation() != cpu ) laerror("permutations can be done only in CPU memory"); -#endif -NRVec r(n); -if(inverse) for(int i=1; i<=n; ++i) r[i-1] = v[p[i]-1]; -else for(int i=1; i<=n; ++i) r[p[i]-1] = v[i-1]; -return r; -} - -template -void NRVec::permuteme(const NRPerm &p, bool inverse) -{ -NRVec tmp=permuted(p,inverse); -for(int i=0; i void NRVec::permuteme(const CyclePerm &p) {