]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add operator> to full matrix iterators.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 2 Mar 2005 00:52:21 +0000 (00:52 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Wed, 2 Mar 2005 00:52:21 +0000 (00:52 +0000)
git-svn-id: https://svn.dealii.org/trunk@9944 0785d39b-7218-0410-832d-ea1e28bc413d

deal.II/doc/news/changes.html
deal.II/lac/include/lac/full_matrix.h
tests/bits/full_matrix_iterator_01.cc [new file with mode: 0644]

index e2d1595b96868ee63d37b557751a2f2784c36173..04b3323277eaf9482f6a627e6253beb99e94423a 100644 (file)
@@ -67,7 +67,8 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
   <li> <p>
        New: The <code>SparseMatrix</code> iterators had no <code>operator
        &gt;</code>, only an <code>operator &lt;</code>. The missing operator
-       is now implemented.
+       is now implemented. The same holds for the <code>FullMatrix</code>
+       class.
        <br> 
        (WB, 2005/03/01)
        </p>
index 89bb1adf03451e5a7cc15630121a00d898c6aa85..91d62bd763ef9170233806afe52273709c75de21 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003, 2004, 2005 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -164,16 +164,21 @@ class FullMatrix : public Table<2,number>
        bool operator != (const const_iterator&) const;
 
                                          /**
-                                          * Comparison
-                                          * operator. Result is true
-                                          * if either the first row
-                                          * number is smaller or if
-                                          * the row numbers are
-                                          * equal and the first
+                                          * Comparison operator. Result is
+                                          * true if either the first row
+                                          * number is smaller or if the row
+                                          * numbers are equal and the first
                                           * index is smaller.
                                           */
        bool operator < (const const_iterator&) const;
 
+                                         /**
+                                          * Comparison operator. Compares just
+                                          * the other way around than the
+                                          * operator above.
+                                          */
+       bool operator > (const const_iterator&) const;
+        
       private:
                                          /**
                                           * Store an object of the
@@ -1184,6 +1189,16 @@ operator < (const const_iterator& other) const
 }
 
 
+template <typename number>
+inline
+bool
+FullMatrix<number>::const_iterator::
+operator > (const const_iterator& other) const
+{
+  return (other < *this);
+}
+
+
 template <typename number>
 inline
 typename FullMatrix<number>::const_iterator
diff --git a/tests/bits/full_matrix_iterator_01.cc b/tests/bits/full_matrix_iterator_01.cc
new file mode 100644 (file)
index 0000000..44cca15
--- /dev/null
@@ -0,0 +1,81 @@
+//----------------------------  full_matrix_iterator_01.cc  ---------------------------
+//    $Id$
+//    Version: $Name$ 
+//
+//    Copyright (C) 2004, 2005 by the deal.II authors
+//
+//    This file is subject to QPL and may not be  distributed
+//    without copyright and license information. Please refer
+//    to the file deal.II/doc/license.html for the  text  and
+//    further information on this license.
+//
+//----------------------------  full_matrix_iterator_01.cc  ---------------------------
+
+
+// like sparse_matrix_iterator_12, but for FullMatrix
+
+#include "../tests.h"
+#include <lac/full_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+  FullMatrix<double> A(3,3);
+
+  const FullMatrix<double>::const_iterator k = A.begin(),
+                                           j = ++A.begin();
+
+  Assert (k < j, ExcInternalError());
+  Assert (j > k, ExcInternalError());
+
+  Assert (!(j < k), ExcInternalError());
+  Assert (!(k > j), ExcInternalError());
+
+  Assert (k != j, ExcInternalError());
+  Assert (!(k == j), ExcInternalError());
+
+  Assert (k == k, ExcInternalError());
+  Assert (!(k != k), ExcInternalError());
+  
+  deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+  std::ofstream logfile("full_matrix_iterator_01.output");
+  deallog.attach(logfile);
+  deallog.depth_console(0);
+
+  try
+    {
+      test ();
+    }
+  catch (std::exception &exc)
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Exception on processing: " << std::endl
+               << exc.what() << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      
+      return 1;
+    }
+  catch (...) 
+    {
+      std::cerr << std::endl << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      std::cerr << "Unknown exception!" << std::endl
+               << "Aborting!" << std::endl
+               << "----------------------------------------------------"
+               << std::endl;
+      return 1;
+    };
+}

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.