From: Wolfgang Bangerth Date: Wed, 2 Mar 2005 00:52:21 +0000 (+0000) Subject: Add operator> to full matrix iterators. X-Git-Tag: v8.0.0~14564 X-Git-Url: https://gitweb.dealii.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=404c0add21a09a6b0198b14f21970e1724cd1d22;p=dealii.git Add operator> to full matrix iterators. git-svn-id: https://svn.dealii.org/trunk@9944 0785d39b-7218-0410-832d-ea1e28bc413d --- diff --git a/deal.II/doc/news/changes.html b/deal.II/doc/news/changes.html index e2d1595b96..04b3323277 100644 --- a/deal.II/doc/news/changes.html +++ b/deal.II/doc/news/changes.html @@ -67,7 +67,8 @@ contributor's names are abbreviated by WB (Wolfgang Bangerth), GK
  • New: The SparseMatrix iterators had no operator >, only an operator <. The missing operator - is now implemented. + is now implemented. The same holds for the FullMatrix + class.
    (WB, 2005/03/01)

    diff --git a/deal.II/lac/include/lac/full_matrix.h b/deal.II/lac/include/lac/full_matrix.h index 89bb1adf03..91d62bd763 100644 --- a/deal.II/lac/include/lac/full_matrix.h +++ b/deal.II/lac/include/lac/full_matrix.h @@ -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 +inline +bool +FullMatrix::const_iterator:: +operator > (const const_iterator& other) const +{ + return (other < *this); +} + + template inline typename FullMatrix::const_iterator diff --git a/tests/bits/full_matrix_iterator_01.cc b/tests/bits/full_matrix_iterator_01.cc new file mode 100644 index 0000000000..44cca15bf1 --- /dev/null +++ b/tests/bits/full_matrix_iterator_01.cc @@ -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 +#include +#include + + +void test () +{ + FullMatrix A(3,3); + + const FullMatrix::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; + }; +}