matrix of permutationalgebra and type conversions

This commit is contained in:
2024-01-18 15:50:11 +01:00
parent 8f61a5d208
commit 680fa93425
4 changed files with 55 additions and 0 deletions

15
mat.h
View File

@@ -31,6 +31,8 @@ namespace LA {
//forward declaration
template<typename T> class NRPerm;
template<typename T, typename R> class WeightPermutation;
template<typename T, typename R> class PermutationAlgebra;
template<typename T> class CyclePerm;
template<typename T> 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<int> &p, const bool direction);
explicit NRMat(const NRPerm<int> &p, const bool direction, const bool parity=false); //permutation matrix
explicit NRMat(const WeightPermutation<int,T> &p, const bool direction);
explicit NRMat(const PermutationAlgebra<int,T> &p, const bool direction);
/***************************************************************************//**
@@ -1556,6 +1560,17 @@ NRMat<typename LA_traits<T>::normtype> NRMat<T>::abs() const {
}
//convert whole matrix between types
template <typename T, typename S>
void NRMat_convert(NRMat<T> &a, const NRMat<S> &b)
{
a.resize(b.nrows(),b.ncols());
for(int i=0; i<b.nrows(); ++i)
for(int j=0; j<b.ncols(); ++j)
a(i,j) = (T) b(i,j);
}