Mentions légales du service

Skip to content
Snippets Groups Projects
Commit 57f6377a authored by hhakim's avatar hhakim
Browse files

Update/Add transpose/adjoint/conj methods of faust_MatGeneric class hierarchy.

parent 688afd90
Branches
Tags
No related merge requests found
...@@ -65,7 +65,8 @@ namespace Faust ...@@ -65,7 +65,8 @@ namespace Faust
void multiply(MatSparse<FPP,Cpu> & M, char opThis) const { throw std::exception();} void multiply(MatSparse<FPP,Cpu> & M, char opThis) const { throw std::exception();}
void multiplyRight(MatSparse<FPP,Cpu> const & M) { throw std::bad_function_call();} void multiplyRight(MatSparse<FPP,Cpu> const & M) { throw std::bad_function_call();}
void transpose() { faust_unsigned_int tmp; tmp = this->dim1; this->dim1 = this->dim2; this->dim2 = tmp; } void transpose() { faust_unsigned_int tmp; tmp = this->dim1; this->dim1 = this->dim2; this->dim2 = tmp; }
void conjugate() { mat = mat.diagonal().conjugate().asDiagonal(); } void conjugate(const bool eval = true) { mat = mat.diagonal().conjugate().asDiagonal(); }
void adjoint() { conjugate(true); transpose(); }
faust_unsigned_int getNonZeros() const { return mat.diagonal().nonZeros(); } faust_unsigned_int getNonZeros() const { return mat.diagonal().nonZeros(); }
matvar_t* toMatIOVar(bool transpose, bool conjugate) const; matvar_t* toMatIOVar(bool transpose, bool conjugate) const;
......
...@@ -183,7 +183,8 @@ namespace Faust ...@@ -183,7 +183,8 @@ namespace Faust
void setZeros(){mat.setZero();nnz=0;} void setZeros(){mat.setZero();nnz=0;}
void setEyes(); void setEyes();
void transpose(); void transpose();
void conjugate(); void conjugate(const bool eval=true);
void adjoint();
typename Eigen::NumTraits<FPP>::Real norm() const {return mat.norm();} typename Eigen::NumTraits<FPP>::Real norm() const {return mat.norm();}
void operator= (const MatSparse<FPP,Cpu>& M); void operator= (const MatSparse<FPP,Cpu>& M);
void operator= (const Faust::MatDense<FPP,Cpu>& Mdense); void operator= (const Faust::MatDense<FPP,Cpu>& Mdense);
......
...@@ -525,9 +525,19 @@ void Faust::MatSparse<FPP,Cpu>::transpose() ...@@ -525,9 +525,19 @@ void Faust::MatSparse<FPP,Cpu>::transpose()
} }
template<typename FPP> template<typename FPP>
void Faust::MatSparse<FPP,Cpu>::conjugate() void Faust::MatSparse<FPP,Cpu>::conjugate(const bool eval /* = true */)
{ {
mat = mat.conjugate().eval(); if(eval)
mat = mat.conjugate().eval();
else
mat = mat.conjugate();
}
template<typename FPP>
void Faust::MatSparse<FPP,Cpu>::adjoint()
{
conjugate(false);
transpose();
} }
template<typename FPP> template<typename FPP>
......
...@@ -129,14 +129,13 @@ namespace Faust ...@@ -129,14 +129,13 @@ namespace Faust
//! \brief Replace this by (this) * A //! \brief Replace this by (this) * A
virtual void multiplyRight(Faust::MatSparse<FPP, DEVICE> const& M) =0; virtual void multiplyRight(Faust::MatSparse<FPP, DEVICE> const& M) =0;
//! \brief transpose the matrix //! \brief transpose the matrix
virtual void transpose()=0; virtual void transpose()=0;
//! \brief Replaces the matrix by its conjugate. //! \brief Replaces the matrix by its conjugate.
virtual void conjugate()=0; virtual void conjugate(const bool eval=true)=0;
virtual void adjoint()=0;
//! \brief return the number of non-zeros element in the matrix //! \brief return the number of non-zeros element in the matrix
virtual faust_unsigned_int getNonZeros()const=0; virtual faust_unsigned_int getNonZeros()const=0;
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment