[GIT] ppl/ppl(sparse_matrices): Dense_Row: added two-argument assign() and assign_if_nonzero().

Module: ppl/ppl Branch: sparse_matrices Commit: 4f2763f9ea5ea650b2c68773eaa41d09375788ab URL: http://www.cs.unipr.it/git/gitweb.cgi?p=ppl/ppl.git;a=commit;h=4f2763f9ea5ea...
Author: Marco Poletti poletti.marco@gmail.com Date: Mon Mar 22 21:35:10 2010 +0100
Dense_Row: added two-argument assign() and assign_if_nonzero().
---
src/Dense_Row.defs.hh | 8 ++++++++ src/Dense_Row.inlines.hh | 11 +++++++++++ 2 files changed, 19 insertions(+), 0 deletions(-)
diff --git a/src/Dense_Row.defs.hh b/src/Dense_Row.defs.hh index 895499c..ba04ad7 100644 --- a/src/Dense_Row.defs.hh +++ b/src/Dense_Row.defs.hh @@ -225,6 +225,14 @@ public: */ void normalize();
+ //! After this call, get(i) == x. + //! Provided for compatibility with Sparse_Row. + void assign(dimension_type i, const Coefficient& x); + + //! Equivalent to <CODE>if (x != 0) find_create(i, x);</CODE>, provided + //! for convenience. Provided for compatibility with Sparse_Row. + void assign_if_nonzero(dimension_type i, const Coefficient& x); + PPL_OUTPUT_DECLARATIONS
/*! \brief diff --git a/src/Dense_Row.inlines.hh b/src/Dense_Row.inlines.hh index 895111c..28152ce 100644 --- a/src/Dense_Row.inlines.hh +++ b/src/Dense_Row.inlines.hh @@ -250,6 +250,17 @@ Dense_Row::normalize() { }
inline void +Dense_Row::assign(dimension_type i, const Coefficient& x) { + (*this)[i] = x; +} + +inline void +Dense_Row::assign_if_nonzero(dimension_type i, const Coefficient& x) { + if (x != 0) + (*this)[i] = x; +} + +inline void Dense_Row::ascii_dump(std::ostream& s) const { row.ascii_dump(s); }
participants (1)
-
Marco Poletti