From 7aece72ea4d6a567f5df6b8d190833ffcfb620ab Mon Sep 17 00:00:00 2001 From: Guido Kanschat Date: Mon, 21 Mar 2005 23:20:41 +0000 Subject: [PATCH] comparison operators added git-svn-id: https://svn.dealii.org/trunk@10196 0785d39b-7218-0410-832d-ea1e28bc413d --- deal.II/lac/include/lac/pointer_matrix.h | 276 ++++++++++++++++------- 1 file changed, 196 insertions(+), 80 deletions(-) diff --git a/deal.II/lac/include/lac/pointer_matrix.h b/deal.II/lac/include/lac/pointer_matrix.h index 37a9890cb1..29a864680c 100644 --- a/deal.II/lac/include/lac/pointer_matrix.h +++ b/deal.II/lac/include/lac/pointer_matrix.h @@ -44,33 +44,75 @@ class PointerMatrixBase : public Subscriptor * the destructor of the derived * class is called. */ - virtual ~PointerMatrixBase (); - - /** - * Matrix-vector product. - */ - virtual void vmult (VECTOR& dst, - const VECTOR& src) const = 0; - - /** - * Tranposed matrix-vector product. - */ - virtual void Tvmult (VECTOR& dst, - const VECTOR& src) const = 0; - - /** - * Matrix-vector product, adding to - * @p dst. - */ - virtual void vmult_add (VECTOR& dst, - const VECTOR& src) const = 0; - - /** - * Tranposed matrix-vector product, - * adding to @p dst. - */ - virtual void Tvmult_add (VECTOR& dst, - const VECTOR& src) const = 0; + virtual ~PointerMatrixBase (); + + /** + * Find out if two matrices point + * to the same object. + */ + bool operator == (const PointerMatrixBase&) const; + + /** + * Find out if two matrices do + * not point to the same object. + */ + bool operator != (const PointerMatrixBase&) const; + + /** + * Find out if this pointer is + * less. + */ + bool operator < (const PointerMatrixBase&) const; + + /** + * Find out if this pointer is + * less or equal. + */ + bool operator <= (const PointerMatrixBase&) const; + + /** + * Find out if this pointer is + * greater. + */ + bool operator > (const PointerMatrixBase&) const; + + /** + * Find out if this pointer is + * greater or equal. + */ + bool operator >= (const PointerMatrixBase&) const; + + + /** + * Matrix-vector product. + */ + virtual void vmult (VECTOR& dst, + const VECTOR& src) const = 0; + + /** + * Tranposed matrix-vector product. + */ + virtual void Tvmult (VECTOR& dst, + const VECTOR& src) const = 0; + + /** + * Matrix-vector product, adding to + * @p dst. + */ + virtual void vmult_add (VECTOR& dst, + const VECTOR& src) const = 0; + + /** + * Tranposed matrix-vector product, + * adding to @p dst. + */ + virtual void Tvmult_add (VECTOR& dst, + const VECTOR& src) const = 0; + + /** + * Get the pointer for comparison. + */ + virtual const void* get() const = 0; }; /** @@ -86,63 +128,69 @@ class PointerMatrixBase : public Subscriptor template class PointerMatrix : public PointerMatrixBase { -public: - /** - * Constructor. The pointer in the - * argument is stored in this - * class. As usual, the lifetime of - * *M must be longer than the - * one of the @p PointerMatrix. - * - * If @p M is zero, no matrix is stored. - */ - PointerMatrix (const MATRIX* M=0); - + public: + /** + * Constructor. The pointer in the + * argument is stored in this + * class. As usual, the lifetime of + * *M must be longer than the + * one of the @p PointerMatrix. + * + * If @p M is zero, no matrix is stored. + */ + PointerMatrix (const MATRIX* M=0); + /** * Return whether the object is * empty. */ - bool empty () const; - - /** - * Assign a new matrix - * pointer. Deletes the old pointer - * and releases its matrix. - * @see SmartPointer - */ - const PointerMatrix& operator= (const MATRIX* M); - - /** - * Matrix-vector product. - */ - virtual void vmult (VECTOR& dst, - const VECTOR& src) const; - - /** - * Tranposed matrix-vector product. - */ - virtual void Tvmult (VECTOR& dst, - const VECTOR& src) const; - - /** - * Matrix-vector product, adding to - * @p dst. - */ - virtual void vmult_add (VECTOR& dst, - const VECTOR& src) const; - - /** - * Tranposed matrix-vector product, - * adding to @p dst. - */ - virtual void Tvmult_add (VECTOR& dst, - const VECTOR& src) const; - -private: - /** - * The pointer to the actual matrix. - */ - SmartPointer m; + bool empty () const; + + /** + * Assign a new matrix + * pointer. Deletes the old pointer + * and releases its matrix. + * @see SmartPointer + */ + const PointerMatrix& operator= (const MATRIX* M); + + /** + * Matrix-vector product. + */ + virtual void vmult (VECTOR& dst, + const VECTOR& src) const; + + /** + * Tranposed matrix-vector product. + */ + virtual void Tvmult (VECTOR& dst, + const VECTOR& src) const; + + /** + * Matrix-vector product, adding to + * @p dst. + */ + virtual void vmult_add (VECTOR& dst, + const VECTOR& src) const; + + /** + * Tranposed matrix-vector product, + * adding to @p dst. + */ + virtual void Tvmult_add (VECTOR& dst, + const VECTOR& src) const; + + private: + /** + * Return the address of the + * matrix for comparison. + */ + virtual const void* get() const; + + /** + * The pointer to the actual matrix. + */ + SmartPointer m; }; @@ -174,6 +222,67 @@ PointerMatrixBase::~PointerMatrixBase () {} + +template +inline +bool +PointerMatrixBase::operator == (const PointerMatrixBase& other) const +{ + return (get() == other.get()); +} + + + +template +inline +bool +PointerMatrixBase::operator != (const PointerMatrixBase& other) const +{ + return (get() != other.get()); +} + + + +template +inline +bool +PointerMatrixBase::operator < (const PointerMatrixBase& other) const +{ + return (get() < other.get()); +} + + + +template +inline +bool +PointerMatrixBase::operator <= (const PointerMatrixBase& other) const +{ + return (get() <= other.get()); +} + + + +template +inline +bool +PointerMatrixBase::operator > (const PointerMatrixBase& other) const +{ + return (get() > other.get()); +} + + + +template +inline +bool +PointerMatrixBase::operator >= (const PointerMatrixBase& other) const +{ + return (get() >= other.get()); +} + + + template PointerMatrix::PointerMatrix (const MATRIX* M) : @@ -238,5 +347,12 @@ PointerMatrix::Tvmult_add (VECTOR& dst, } +template +inline const void* +PointerMatrix::get () const +{ + return m; +} + #endif -- 2.39.5