nrvec::permuteme moved from permutation.h to vec.h

This commit is contained in:
Jiri Pittner 2023-07-30 15:26:38 +02:00
parent 3c572e212d
commit 757a76844e
3 changed files with 12 additions and 9 deletions

View File

@ -257,14 +257,6 @@ else for(int i=1; i<=n; ++i) r[p[i]-1] = v[i-1];
return r; return r;
} }
template<typename T>
void NRVec<T>::permuteme(const NRPerm<int> &p, bool inverse)
{
NRVec<T> tmp=permuted(p,inverse);
for(int i=0; i<size(); ++i) v[i] = tmp.v[i];
}
}//namespace }//namespace
#endif #endif

4
vec.cc
View File

@ -767,6 +767,10 @@ NRVec<std::complex<double> > complexify(const NRVec<double> &rhs) {
#endif #endif
return r; return r;
} }
template<typename T> template<typename T>
void NRVec<T>::permuteme(const CyclePerm<int> &p) void NRVec<T>::permuteme(const CyclePerm<int> &p)
{ {

9
vec.h
View File

@ -358,7 +358,14 @@ public:
//! permute vector elements //! permute vector elements
const NRVec permuted(const NRPerm<int> &p, const bool inverse=false) const; const NRVec permuted(const NRPerm<int> &p, const bool inverse=false) const;
void permuteme(const CyclePerm<int> &p); //in place void permuteme(const CyclePerm<int> &p); //in place
void permuteme(const NRPerm<int> &p, const bool inverse=false); //formally in place, but allocates a copy void permuteme(const NRPerm<int> &p, const bool inverse=false)
{
NRVec<T> tmp=permuted(p,inverse);
copyonwrite();
for(int i=0; i<size(); ++i) v[i] = tmp.v[i];
}
//! compute the sum of the absolute values of the elements of this vector //! compute the sum of the absolute values of the elements of this vector
inline const typename LA_traits<T>::normtype asum() const; inline const typename LA_traits<T>::normtype asum() const;