]> https://gitweb.dealii.org/ - dealii.git/commitdiff
comparison operators added
authorGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 21 Mar 2005 23:20:41 +0000 (23:20 +0000)
committerGuido Kanschat <dr.guido.kanschat@gmail.com>
Mon, 21 Mar 2005 23:20:41 +0000 (23:20 +0000)
git-svn-id: https://svn.dealii.org/trunk@10196 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/lac/include/lac/pointer_matrix.h

index 37a9890cb1a8780a804f919f13b42019bdde46bd..29a864680caf583d86eca77491f81f4c76fe3c51 100644 (file)
@@ -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<VECTOR>&) const;
+    
+                                    /**
+                                     * Find out if two matrices do
+                                     * not point to the same object.
+                                     */
+    bool operator != (const PointerMatrixBase<VECTOR>&) const;
+    
+                                    /**
+                                     * Find out if this pointer is
+                                     * less.
+                                     */
+    bool operator < (const PointerMatrixBase<VECTOR>&) const;
+    
+                                    /**
+                                     * Find out if this pointer is
+                                     * less or equal.
+                                     */
+    bool operator <= (const PointerMatrixBase<VECTOR>&) const;
+    
+                                    /**
+                                     * Find out if this pointer is
+                                     * greater.
+                                     */
+    bool operator > (const PointerMatrixBase<VECTOR>&) const;
+    
+                                    /**
+                                     * Find out if this pointer is
+                                     * greater or equal.
+                                     */
+    bool operator >= (const PointerMatrixBase<VECTOR>&) 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 MATRIX, class VECTOR>
 class PointerMatrix : public PointerMatrixBase<VECTOR>
 {
-public:
-                                  /**
-                                   * Constructor.  The pointer in the
-                                   * argument is stored in this
-                                   * class. As usual, the lifetime of
-                                   * <tt>*M</tt> 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
+                                     * <tt>*M</tt> 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<const MATRIX> 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<const MATRIX> m;
 };
 
 
@@ -174,6 +222,67 @@ PointerMatrixBase<VECTOR>::~PointerMatrixBase ()
 {}
 
 
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator == (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() == other.get());
+}
+
+
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator != (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() != other.get());
+}
+
+
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator < (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() < other.get());
+}
+
+
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator <= (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() <= other.get());
+}
+
+
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator > (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() > other.get());
+}
+
+
+
+template<class VECTOR>
+inline
+bool
+PointerMatrixBase<VECTOR>::operator >= (const PointerMatrixBase<VECTOR>& other) const
+{
+  return (get() >= other.get());
+}
+
+
+
 template<class MATRIX, class VECTOR>
 PointerMatrix<MATRIX, VECTOR>::PointerMatrix (const MATRIX* M)
   :
@@ -238,5 +347,12 @@ PointerMatrix<MATRIX, VECTOR>::Tvmult_add (VECTOR& dst,
 }
 
 
+template<class MATRIX, class VECTOR>
+inline const void*
+PointerMatrix<MATRIX, VECTOR>::get () const
+{
+  return m;
+}
+
 
 #endif

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.