diff --git a/mat.cc b/mat.cc index 3a58b6a..469246e 100644 --- a/mat.cc +++ b/mat.cc @@ -3173,6 +3173,27 @@ T alpha= parity? p.parity():1; axpy(alpha,p,direction); } +template +NRMat::NRMat(const WeightPermutation &wp, const bool direction) +{ +int n=wp.size(); +resize(n,n); +clear(); +axpy(wp.weight,wp.perm,direction); +} + +template +NRMat::NRMat(const PermutationAlgebra &ap, const bool direction) +{ +int na= ap.size(); +if(na<=0) laerror("cannot deduce matrix size from empty PermutationAlgebra"); +int n=ap[0].size(); +resize(n,n); +clear(); +for(int i=0; i class NRPerm; +template class WeightPermutation; +template class PermutationAlgebra; template class CyclePerm; template class NRMat_from1; @@ -136,6 +138,8 @@ public: void scale_col(const int i, const T f); //in place void axpy(const T alpha, const NRPerm &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); /***************************************************************************//** @@ -1556,6 +1560,17 @@ NRMat::normtype> NRMat::abs() const { } +//convert whole matrix between types +template +void NRMat_convert(NRMat &a, const NRMat &b) +{ +a.resize(b.nrows(),b.ncols()); +for(int i=0; i>(std::istream &s, NRSMat &x) { #endif } +//convert whole matrix between types +template +void NRSMat_convert(NRSMat &a, const NRSMat &b) +{ +a.resize(b.nrows(),b.ncols()); +for(int i=0; i objects and scalars diff --git a/vec.h b/vec.h index 74fd24b..bb2443c 100644 --- a/vec.h +++ b/vec.h @@ -2039,6 +2039,15 @@ for(int next=0; next +void NRVec_convert(NRVec &a, const NRVec &b) +{ +a.resize(b.size()); +for(int i=0; i