Skip to content
Snippets Groups Projects
Commit ff386db2 authored by Christoph Lehmann's avatar Christoph Lehmann
Browse files

[MaL] added componentwiseDivide to BLAS

parent c46ecaac
No related branches found
No related tags found
No related merge requests found
...@@ -19,6 +19,15 @@ ...@@ -19,6 +19,15 @@
namespace MathLib { namespace BLAS namespace MathLib { namespace BLAS
{ {
// Explicit specialization
// Computes w = x/y componentwise.
template<>
void componentwiseDivide(Eigen::VectorXd& w,
Eigen::VectorXd const& x, Eigen::VectorXd const& y)
{
w.noalias() = x.cwiseQuotient(y);
}
// Explicit specialization // Explicit specialization
// Computes the Manhattan norm of x // Computes the Manhattan norm of x
template<> template<>
...@@ -90,6 +99,15 @@ void axpby(PETScVector& y, double const a, double const b, PETScVector const& x) ...@@ -90,6 +99,15 @@ void axpby(PETScVector& y, double const a, double const b, PETScVector const& x)
VecAXPBY(*y.getRawVector(), a, b, *x.getRawVector()); VecAXPBY(*y.getRawVector(), a, b, *x.getRawVector());
} }
// Explicit specialization
// Computes w = x/y componentwise.
template<>
void componentwiseDivide(PETScVector& w,
PETScVector const& x, PETScVector const& y)
{
VecPointwiseDivide(*w.getRawVector(), *x.getRawVector(), *y.getRawVector());
}
// Explicit specialization // Explicit specialization
// Computes the Manhattan norm of x // Computes the Manhattan norm of x
template<> template<>
...@@ -224,6 +242,16 @@ void axpby(EigenVector& y, double const a, double const b, EigenVector const& x) ...@@ -224,6 +242,16 @@ void axpby(EigenVector& y, double const a, double const b, EigenVector const& x)
y.getRawVector() = a*x.getRawVector() + b*y.getRawVector(); y.getRawVector() = a*x.getRawVector() + b*y.getRawVector();
} }
// Explicit specialization
// Computes w = x/y componentwise.
template<>
void componentwiseDivide(EigenVector& w,
EigenVector const& x, EigenVector const& y)
{
w.getRawVector().noalias() =
x.getRawVector().cwiseQuotient(y.getRawVector());
}
// Explicit specialization // Explicit specialization
// Computes the Manhattan norm of x // Computes the Manhattan norm of x
template<> template<>
......
...@@ -66,6 +66,11 @@ void axpby(MatrixOrVector& y, double const a, double const b, MatrixOrVector con ...@@ -66,6 +66,11 @@ void axpby(MatrixOrVector& y, double const a, double const b, MatrixOrVector con
y = a*x + b*y; y = a*x + b*y;
} }
//! Computes \f$w = x/y\f$ componentwise.
template<typename MatrixOrVector>
void componentwiseDivide(MatrixOrVector& w,
MatrixOrVector const& x, MatrixOrVector const& y);
//! Computes the Manhattan norm of \c x. //! Computes the Manhattan norm of \c x.
template<typename MatrixOrVector> template<typename MatrixOrVector>
double norm1(MatrixOrVector const& x); double norm1(MatrixOrVector const& x);
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment