--- /dev/null
+//---------------------------- sparse_matrix_iterator_02.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_02.cc ---------------------------
+
+
+// test setting some elements and reading them back from a const matrix
+// iterator
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set (i,j, i*j);
+
+ SparseMatrix<double>::const_iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ {
+ deallog << i->row() << ' ' << i->column() << ' '
+ << i->value() << std::endl;
+ Assert (std::fabs(i->value() - i->row()*i->column()) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_02.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_03.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_03.cc ---------------------------
+
+
+// test setting some elements and reading them back from a non-const matrix
+// iterator
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set (i,j, i*j);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ {
+ deallog << i->row() << ' ' << i->column() << ' '
+ << i->value() << std::endl;
+ Assert (std::fabs(i->value() - i->row()*i->column()) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_03.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_04.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_04.cc ---------------------------
+
+// test setting some elements using a non-const matrix iterator and operator=,
+// and reading them back through the matrix itself
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+ SparseMatrix<double> m(sp);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ i->value() = i->row()*i->column();
+
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ {
+ deallog << i << ' ' << j << ' ' << m.el(i,j)
+ << std::endl;
+ Assert (std::fabs(m.el(i,j)-i*j) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_04.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_05.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_05.cc ---------------------------
+
+// test setting some elements using a non-const matrix iterator and operator+=,
+// and reading them back through the matrix itself
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set(i,j,1.);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ i->value() += i->row()*i->column();
+
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ {
+ deallog << i << ' ' << j << ' ' << m.el(i,j)
+ << std::endl;
+ Assert (std::fabs(m.el(i,j)-(1.+i*j)) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_05.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_06.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_06.cc ---------------------------
+
+// test setting some elements using a non-const matrix iterator and operator-=,
+// and reading them back through the matrix itself
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set(i,j,1.);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ i->value() -= i->row()*i->column();
+
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ {
+ deallog << i << ' ' << j << ' ' << m.el(i,j)
+ << std::endl;
+ Assert (std::fabs(m.el(i,j)-(1.-i*j)) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_06.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_07.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_07.cc ---------------------------
+
+// test setting some elements using a non-const matrix iterator and operator*=,
+// and reading them back through the matrix itself
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set(i,j,i*j);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ i->value() *= 2;
+
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ {
+ deallog << i << ' ' << j << ' ' << m.el(i,j)
+ << std::endl;
+ Assert (std::fabs(m.el(i,j)-(2.*i*j)) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_07.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;
+ };
+}
--- /dev/null
+//---------------------------- sparse_matrix_iterator_08.cc ---------------------------
+// $Id$
+// Version: $Name$
+//
+// Copyright (C) 2004 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.
+//
+//---------------------------- sparse_matrix_iterator_08.cc ---------------------------
+
+// test setting some elements using a non-const matrix iterator and operator/=,
+// and reading them back through the matrix itself
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test ()
+{
+ SparsityPattern sp (5,5,3);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ m.set(i,j,i*j);
+
+ SparseMatrix<double>::iterator i = m.begin();
+ for (; i!=m.end(); ++i)
+ i->value() /= 2;
+
+ for (unsigned int i=0; i<5; ++i)
+ for (unsigned int j=0; j<5; ++j)
+ if (((i+2*j+1) % 3 == 0)
+ ||
+ (i==j))
+ {
+ deallog << i << ' ' << j << ' ' << m.el(i,j)
+ << std::endl;
+ Assert (std::fabs(m.el(i,j)-(i*j/2.)) < 1e-14,
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_iterator_08.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;
+ };
+}
--- /dev/null
+
+DEAL::0 0 0.00000
+DEAL::0 1 0.00000
+DEAL::0 4 0.00000
+DEAL::1 1 1.00000
+DEAL::1 2 2.00000
+DEAL::2 2 4.00000
+DEAL::2 0 0.00000
+DEAL::2 3 6.00000
+DEAL::3 3 9.00000
+DEAL::3 1 3.00000
+DEAL::3 4 12.0000
+DEAL::4 4 16.0000
+DEAL::4 2 8.00000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 0.00000
+DEAL::0 1 0.00000
+DEAL::0 4 0.00000
+DEAL::1 1 1.00000
+DEAL::1 2 2.00000
+DEAL::2 2 4.00000
+DEAL::2 0 0.00000
+DEAL::2 3 6.00000
+DEAL::3 3 9.00000
+DEAL::3 1 3.00000
+DEAL::3 4 12.0000
+DEAL::4 4 16.0000
+DEAL::4 2 8.00000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 0.00000
+DEAL::0 1 0.00000
+DEAL::0 4 0.00000
+DEAL::1 1 1.00000
+DEAL::1 2 2.00000
+DEAL::2 0 0.00000
+DEAL::2 2 4.00000
+DEAL::2 3 6.00000
+DEAL::3 1 3.00000
+DEAL::3 3 9.00000
+DEAL::3 4 12.0000
+DEAL::4 2 8.00000
+DEAL::4 4 16.0000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 1.00000
+DEAL::0 1 1.00000
+DEAL::0 4 1.00000
+DEAL::1 1 2.00000
+DEAL::1 2 3.00000
+DEAL::2 0 1.00000
+DEAL::2 2 5.00000
+DEAL::2 3 7.00000
+DEAL::3 1 4.00000
+DEAL::3 3 10.0000
+DEAL::3 4 13.0000
+DEAL::4 2 9.00000
+DEAL::4 4 17.0000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 1.00000
+DEAL::0 1 1.00000
+DEAL::0 4 1.00000
+DEAL::1 1 0.00000
+DEAL::1 2 -1.00000
+DEAL::2 0 1.00000
+DEAL::2 2 -3.00000
+DEAL::2 3 -5.00000
+DEAL::3 1 -2.00000
+DEAL::3 3 -8.00000
+DEAL::3 4 -11.0000
+DEAL::4 2 -7.00000
+DEAL::4 4 -15.0000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 0.00000
+DEAL::0 1 0.00000
+DEAL::0 4 0.00000
+DEAL::1 1 2.00000
+DEAL::1 2 4.00000
+DEAL::2 0 0.00000
+DEAL::2 2 8.00000
+DEAL::2 3 12.0000
+DEAL::3 1 6.00000
+DEAL::3 3 18.0000
+DEAL::3 4 24.0000
+DEAL::4 2 16.0000
+DEAL::4 4 32.0000
+DEAL::OK
--- /dev/null
+
+DEAL::0 0 0.00000
+DEAL::0 1 0.00000
+DEAL::0 4 0.00000
+DEAL::1 1 0.500000
+DEAL::1 2 1.00000
+DEAL::2 0 0.00000
+DEAL::2 2 2.00000
+DEAL::2 3 3.00000
+DEAL::3 1 1.50000
+DEAL::3 3 4.50000
+DEAL::3 4 6.00000
+DEAL::4 2 4.00000
+DEAL::4 4 8.00000
+DEAL::OK