//---------------------------- petsc_01.cc ---------------------------
-// check setting elements in a petsc matrix using set()
+// check setting elements in a petsc matrix using
+// petsc_wrappers::SparseMatrix::set()
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
//---------------------------- petsc_02.cc ---------------------------
-// check setting elements in a petsc matrix using add()
+// check setting elements in a petsc matrix using
+// petsc_wrappers::SparseMatrix::add()
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
//---------------------------- petsc_05.cc ---------------------------
-// check querying the number of nonzero elements
+// check querying the number of nonzero elements in
+// petsc_wrappers::SparseMatrix
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
//---------------------------- petsc_06.cc ---------------------------
-// check l1_norm
+// check petsc_wrappers::SparseMatrix::l1_norm
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
//---------------------------- petsc_07.cc ---------------------------
-// check linfty_norm
+// check petsc_wrappers::SparseMatrix::linfty_norm
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
//---------------------------- petsc_08.cc ---------------------------
-// check l2_norm
+// check petsc_wrappers::SparseMatrix::l2_norm
#include "../tests.h"
#include <lac/petsc_sparse_matrix.h>
--- /dev/null
+//---------------------------- petsc_09.cc ---------------------------
+// petsc_09.cc,v 1.4 2003/07/03 10:31:46 guido Exp
+// Version:
+//
+// Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+// 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.
+//
+//---------------------------- petsc_09.cc ---------------------------
+
+
+// check petsc_wrapper::SparseMatrix::operator *=
+
+#include "../tests.h"
+#include <lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (petsc_wrappers::SparseMatrix &m)
+{
+ // first set a few entries
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ m.set (i,j, i*j*.5+.5);
+
+ m.compress ();
+
+ // then multiply everything by 1.25 and
+ // make sure we retrieve the values we
+ // expect
+ m *= 1.25;
+
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)*1.25, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_09.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ PetscFinalize();
+ }
+ 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
+//---------------------------- petsc_10.cc ---------------------------
+// petsc_10.cc,v 1.4 2003/07/03 10:31:46 guido Exp
+// Version:
+//
+// Copyright (C) 2004 by the deal.II authors and Anna Schneebeli
+//
+// 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.
+//
+//---------------------------- petsc_10.cc ---------------------------
+
+
+// check petsc_wrapper::SparseMatrix::operator /=
+
+#include "../tests.h"
+#include <lac/petsc_sparse_matrix.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (petsc_wrappers::SparseMatrix &m)
+{
+ // first set a few entries
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ m.set (i,j, i*j*.5+.5);
+
+ m.compress ();
+
+ // then divide everything by 4/3 and
+ // make sure we retrieve the values we
+ // expect
+ m /= 4./3.;
+
+ for (unsigned int i=0; i<m.m(); ++i)
+ for (unsigned int j=0; j<m.m(); ++j)
+ if ((i+2*j+1) % 3 == 0)
+ {
+ Assert (m(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ Assert (m.el(i,j) == (i*j*.5+.5)/4*3, ExcInternalError());
+ }
+ else
+ {
+ Assert (m(i,j) == 0, ExcInternalError());
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_10.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::SparseMatrix m (5,5,3);
+ test (m);
+ }
+ PetscFinalize();
+ }
+ 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;
+ };
+}