for (unsigned int j=0; j<m.m(); ++j)
if ((i+2*j+1) % 3 == 0)
m.set (i,j, i*j*.5+.5);
+
// then add the same elements again
for (unsigned int i=0; i<m.m(); ++i)
for (unsigned int j=0; j<m.m(); ++j)
--- /dev/null
+//---------------------------- petsc_17.cc ---------------------------
+// petsc_11.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_17.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::l1_norm()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.l1_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_17.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_18.cc ---------------------------
+// petsc_11.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_18.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::l2_norm()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.l2_norm() == std::sqrt(norm), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_18.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_19.cc ---------------------------
+// petsc_11.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_19.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::linfty_norm()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm = std::max(norm,fabs(i));
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.linfty_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_19.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_20.cc ---------------------------
+// petsc_11.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_20.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator *=
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 5/4
+ v *= 5./4.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*5./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_20.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_21.cc ---------------------------
+// petsc_11.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_21.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator /=
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 3/4
+ v /= 4./3.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*3./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_21.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_22.cc ---------------------------
+// petsc_11.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_22.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator*(Vector) on two vectors that are
+// orthogonal
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector, but disjoint sets of elements
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i;
+ else
+ w(i) = i;
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_22.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_23.cc ---------------------------
+// petsc_11.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_23.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator*(Vector) on two vectors that are
+// not orthogonal
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector, and record the expected scalar
+ // product
+ double product = 0;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ {
+ w(i) = i+1.;
+ product += i*(i+1);
+ }
+ }
+
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == product, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_23.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_24.cc ---------------------------
+// petsc_11.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_24.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::clear()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v.clear ();
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_24.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_25.cc ---------------------------
+// petsc_11.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_25.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator = (PetscScalar) with setting to zero
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v = 0;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_25.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_26.cc ---------------------------
+// petsc_11.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_26.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator = (PetscScalar) with setting to a
+// nonzero value
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ const unsigned int sz = v.size();
+ v = 2;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == std::sqrt(4.*sz), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_26.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_27.cc ---------------------------
+// petsc_11.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_27.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator = (Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it
+ petsc_wrappers::Vector w (v.size());
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < 1e-14*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_27.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_28.cc ---------------------------
+// petsc_11.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_28.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator = (Vector), except that we don't
+// resize the vector to be copied to beforehand
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it to a vector of different
+ // size
+ petsc_wrappers::Vector w (1);
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < 1e-14*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_28.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_29.cc ---------------------------
+// petsc_11.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_29.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::reinit(fast)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ v.reinit (13, true);
+
+ Assert (v.size() == 13, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_29.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_30.cc ---------------------------
+// petsc_11.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_30.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::reinit(!fast)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then resize with setting to zero
+ v.reinit (13, false);
+
+ Assert (v.size() == 13, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_30.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_31.cc ---------------------------
+// petsc_11.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_31.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::l2_norm()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.norm_sqr() - norm) < 1e-14*norm,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_31.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_32.cc ---------------------------
+// petsc_11.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_32.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::l2_norm()
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i;
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.mean_value() - sum/v.size()) < 1e-14*sum/v.size(),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_32.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_33.cc ---------------------------
+// petsc_11.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_33.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::lp_norm(3)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.lp_norm(3) - std::pow(sum, 1./3.)) <
+ 1e-14*std::pow(sum, 1./3.),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_33.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_34.cc ---------------------------
+// petsc_11.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_34.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::all_zero
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // set them to zero again
+ v = 0;
+
+ // then check all_zero
+ Assert (v.all_zero() == true, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_34.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_35.cc ---------------------------
+// petsc_11.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_35.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator+=(Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v += w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+i+1., ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_35.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_36.cc ---------------------------
+// petsc_11.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_36.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::operator-=(Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v -= w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i-(i+1.), ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_36.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_37.cc ---------------------------
+// petsc_11.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_37.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::add (scalar)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ v.compress ();
+
+ v.add (1.);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (v(i) == i+1., ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_37.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ test (v);
+ }
+ 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_38.cc ---------------------------
+// petsc_11.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_38.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::add(Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_38.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_39.cc ---------------------------
+// petsc_11.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_39.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::add(scalar, Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_39.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_40.cc ---------------------------
+// petsc_11.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_40.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::add(s,V,s,V)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w,
+ petsc_wrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.add (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_40.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ petsc_wrappers::Vector x (100);
+ test (v,w,x);
+ }
+ 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_41.cc ---------------------------
+// petsc_11.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_41.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::sadd(s, Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_41.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_42.cc ---------------------------
+// petsc_11.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_42.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::sadd(scalar, scalar, Vector)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (3, 2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 3*i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_42.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_43.cc ---------------------------
+// petsc_11.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_43.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::sadd(s,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w,
+ petsc_wrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.sadd (1.5, 2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_43.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ petsc_wrappers::Vector x (100);
+ test (v,w,x);
+ }
+ 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_44.cc ---------------------------
+// petsc_11.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_44.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::sadd(s,s,V,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w,
+ petsc_wrappers::Vector &x,
+ petsc_wrappers::Vector &y)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ y(i) = i+3.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+ y.compress ();
+
+ v.sadd (1.5, 2, w, 3, x, 4, y);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (y(i) == i+3., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.)+4*(i+3), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_44.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ petsc_wrappers::Vector x (100);
+ petsc_wrappers::Vector y (100);
+ test (v,w,x,y);
+ }
+ 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_45.cc ---------------------------
+// petsc_11.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_45.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::scale
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.scale (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_45.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_46.cc ---------------------------
+// petsc_11.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_46.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::equ (s,V)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.equ (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_46.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ test (v,w);
+ }
+ 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_47.cc ---------------------------
+// petsc_11.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_47.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::equ (s,V,s,V)
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w,
+ petsc_wrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.equ (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_47.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ petsc_wrappers::Vector x (100);
+ test (v,w,x);
+ }
+ 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_48.cc ---------------------------
+// petsc_11.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_48.cc ---------------------------
+
+
+// check petsc_wrapper::Vector::ratio
+
+#include "../tests.h"
+#include <lac/petsc_vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (petsc_wrappers::Vector &v,
+ petsc_wrappers::Vector &w,
+ petsc_wrappers::Vector &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.ratio (w, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (std::fabs(v(i) - (i+1.)/(i+2.)) < 1e-14*v(i),
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main (int argc,char **argv)
+{
+ std::ofstream logfile("petsc_48.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ PetscInitialize(&argc,&argv,0,0);
+ {
+ petsc_wrappers::Vector v (100);
+ petsc_wrappers::Vector w (100);
+ petsc_wrappers::Vector x (100);
+ test (v,w,x);
+ }
+ 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
+//---------------------------- sparse_matrix_03.cc ---------------------------
+// sparse_matrix_03.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.
+//
+//---------------------------- sparse_matrix_03.cc ---------------------------
+
+
+// check setting elements in a sparse matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations, but it shouldn't be a
+// problem with the deal.II matrices. worth checking anyway
+//
+// in contrast to petsc_03, we set and add the same elements here twice, to
+// get double the original value
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+
+
+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)
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+
+ // 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);
+ // then add the same elements again
+ 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.add (i,j, i*j*.5+.5);
+
+ // then make sure we retrieve the correct
+ // ones
+ 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) == 2*(i*j*.5+.5), ExcInternalError());
+ Assert (m.el(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+ }
+ else
+ {
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_03a.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_03.cc ---------------------------
+// sparse_matrix_03.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.
+//
+//---------------------------- sparse_matrix_03.cc ---------------------------
+
+
+// check setting elements in a sparse matrix using set() and add()
+// intermixed. this poses PETSc some problems, since one has to flush some
+// buffer in between these two types of operations, but it shouldn't be a
+// problem with the deal.II matrices. worth checking anyway
+//
+// in contrast to petsc_03, we set and add the same elements here twice, to
+// get double the original value
+
+#include "../tests.h"
+#include <lac/sparse_matrix.h>
+#include <fstream>
+
+
+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)
+ sp.add (i,j);
+ sp.compress ();
+
+ SparseMatrix<double> m(sp);
+
+ // 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);
+ // then add the same elements again
+ 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.add (i,j, i*j*.5+.5);
+
+ // then make sure we retrieve the correct
+ // ones
+ 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) == 2*(i*j*.5+.5), ExcInternalError());
+ Assert (m.el(i,j) == 2*(i*j*.5+.5), ExcInternalError());
+ }
+ else
+ {
+ Assert (m.el(i,j) == 0, ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("sparse_matrix_03b.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
+//---------------------------- vector_11.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_11.cc ---------------------------
+
+
+// check Vector<double>::size()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the vector
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) = i;
+
+ v.compress ();
+
+ Assert (v.size() == 100, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_11.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_12.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_12.cc ---------------------------
+
+
+// check Vector<double>::operator() in set-mode
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_12.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_13.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_13.cc ---------------------------
+
+
+// check Vector<double>::operator() in add-mode
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) += i;
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_13.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_14.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_14.cc ---------------------------
+
+
+// check Vector<double>::operator() in set/add-mode alternatingly
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ bool flag = false;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ if (flag == true)
+ v(i) += i;
+ else
+ v(i) = i;
+ flag = !flag;
+
+ pattern[i] = true;
+ }
+
+ v.compress ();
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_14.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_15.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_15.cc ---------------------------
+
+
+// check Vector<double>::operator() in set/add-mode alternatingly, but
+// writing to the same elements
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) += i;
+
+ v.compress ();
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == 2*i)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_15.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_16.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_16.cc ---------------------------
+
+
+// check Vector<double>::operator() in set/add-mode alternatingly, but
+// writing and overwriting the same elements
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) += i;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ v(i) = i;
+
+ v.compress ();
+
+ // check that they are ok, and this time
+ // all of them
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_16.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_17.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_17.cc ---------------------------
+
+
+// check Vector<double>::l1_norm()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.l1_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_17.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_18.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_18.cc ---------------------------
+
+
+// check Vector<double>::l2_norm()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.l2_norm() == std::sqrt(norm), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_18.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_19.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_19.cc ---------------------------
+
+
+// check Vector<double>::linfty_norm()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm = std::max(norm,fabs(i));
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (v.linfty_norm() == norm, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_19.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_20.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_20.cc ---------------------------
+
+
+// check Vector<double>::operator *=
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 5/4
+ v *= 5./4.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*5./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_20.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_21.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_21.cc ---------------------------
+
+
+// check Vector<double>::operator /=
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set only certain elements of the
+ // vector. have a bit pattern of where we
+ // actually wrote elements to
+ std::vector<bool> pattern (v.size(), false);
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ pattern[i] = true;
+ }
+ v.compress ();
+
+ // multiply v with 3/4
+ v /= 4./3.;
+
+ // check that the entries are ok
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (((pattern[i] == true) && (v(i) == i*3./4.)
+ ||
+ (pattern[i] == false) && (v(i) == 0)),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_21.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_22.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_22.cc ---------------------------
+
+
+// check Vector<double>::operator*(Vector) on two vectors that are
+// orthogonal
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector, but disjoint sets of elements
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i;
+ else
+ w(i) = i;
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_22.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_23.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_23.cc ---------------------------
+
+
+// check Vector<double>::operator*(Vector) on two vectors that are
+// not orthogonal
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector, and record the expected scalar
+ // product
+ double product = 0;
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ {
+ w(i) = i+1.;
+ product += i*(i+1);
+ }
+ }
+
+ v.compress ();
+ w.compress ();
+
+ // make sure the scalar product is zero
+ Assert (v*w == product, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_23.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_24.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_24.cc ---------------------------
+
+
+// check Vector<double>::clear()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v.clear ();
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_24.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_25.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_25.cc ---------------------------
+
+// check Vector::operator = (Scalar) with setting to zero
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then clear it again and make sure the
+ // vector is really empty
+ const unsigned int sz = v.size();
+ v = 0;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+int main ()
+{
+ std::ofstream logfile("vector_25.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_26.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_26.cc ---------------------------
+
+// check Vector::operator = (scalar) with setting to a
+// nonzero value
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ const unsigned int sz = v.size();
+ v = 2;
+ Assert (v.size() == sz, ExcInternalError());
+ Assert (v.l2_norm() == std::sqrt(4.*sz), ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+int main ()
+{
+ std::ofstream logfile("vector_26.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_27.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_27.cc ---------------------------
+
+
+// check Vector<double>::operator = (Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it
+ Vector<double> w (v.size());
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < 1e-14*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_27.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_28.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_28.cc ---------------------------
+
+
+// check Vector<double>::operator = (Vector), except that we don't
+// resize the vector to be copied to beforehand
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then copy it to a vector of different
+ // size
+ Vector<double> w (1);
+ w = v;
+
+ // make sure they're equal
+ deallog << v*w << ' ' << v.l2_norm() * w.l2_norm()
+ << ' ' << v*w - v.l2_norm() * w.l2_norm() << std::endl;
+ Assert (std::fabs(v*w - v.l2_norm() * w.l2_norm()) < 1e-14*(v*w),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_28.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_29.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_29.cc ---------------------------
+
+
+// check Vector<double>::reinit(fast)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ v.reinit (13, true);
+
+ Assert (v.size() == 13, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_29.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_30.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_30.cc ---------------------------
+
+
+// check Vector<double>::reinit(!fast)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some entries of the vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ if (i%3 == 0)
+ v(i) = i+1.;
+ v.compress ();
+
+ // then resize with setting to zero
+ v.reinit (13, false);
+
+ Assert (v.size() == 13, ExcInternalError());
+ Assert (v.l2_norm() == 0, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_30.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_31.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_31.cc ---------------------------
+
+
+// check Vector<double>::l2_norm()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double norm = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ norm += std::fabs(1.*i)*std::fabs(1.*i);
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.norm_sqr() - norm) < 1e-14*norm,
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_31.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_32.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_32.cc ---------------------------
+
+
+// check Vector<double>::l2_norm()
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i;
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.mean_value() - sum/v.size()) < 1e-14*sum/v.size(),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_32.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_33.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_33.cc ---------------------------
+
+
+// check Vector<double>::lp_norm(3)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // then check the norm
+ Assert (std::fabs(v.lp_norm(3) - std::pow(sum, 1./3.)) <
+ 1e-14*std::pow(sum, 1./3.),
+ ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_33.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_34.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_34.cc ---------------------------
+
+
+// check Vector<double>::all_zero
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ // set some elements of the vector
+ double sum = 0;
+ for (unsigned int i=0; i<v.size(); i+=1+i)
+ {
+ v(i) = i;
+ sum += i*i*i;
+ }
+ v.compress ();
+
+ // set them to zero again
+ v = 0;
+
+ // then check all_zero
+ Assert (v.all_zero() == true, ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_34.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_35.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_35.cc ---------------------------
+
+
+// check Vector<double>::operator+=(Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v += w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+i+1., ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_35.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_36.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_36.cc ---------------------------
+
+
+// check Vector<double>::operator-=(Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ // set only certain elements of each
+ // vector
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ if (i%3 == 0)
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v -= w;
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ if (i%3 == 0)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i-(i+1.), ExcInternalError());
+ }
+ else
+ {
+ Assert (w(i) == 0, ExcInternalError());
+ Assert (v(i) == i, ExcInternalError());
+ }
+ }
+
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_36.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_37.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_37.cc ---------------------------
+
+
+// check Vector<double>::add (scalar)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ v(i) = i;
+
+ v.compress ();
+
+ v.add (1.);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ Assert (v(i) == i+1., ExcInternalError());
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_37.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ test (v);
+ }
+ 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
+//---------------------------- vector_38.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_38.cc ---------------------------
+
+
+// check Vector<double>::add(Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_38.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_39.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_39.cc ---------------------------
+
+
+// check Vector<double>::add(scalar, Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.add (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_39.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_40.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_40.cc ---------------------------
+
+
+// check Vector<double>::add(s,V,s,V)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w,
+ Vector<double> &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.add (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_40.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ Vector<double> x (100);
+ test (v,w,x);
+ }
+ 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
+//---------------------------- vector_41.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_41.cc ---------------------------
+
+
+// check Vector<double>::sadd(s, Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*i+(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_41.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_42.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_42.cc ---------------------------
+
+
+// check Vector<double>::sadd(scalar, scalar, Vector)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.sadd (3, 2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 3*i+2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_42.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_43.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_43.cc ---------------------------
+
+
+// check Vector<double>::sadd(s,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w,
+ Vector<double> &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.sadd (1.5, 2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_43.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ Vector<double> x (100);
+ test (v,w,x);
+ }
+ 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
+//---------------------------- vector_44.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_44.cc ---------------------------
+
+
+// check Vector<double>::sadd(s,s,V,s,V,s,V)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w,
+ Vector<double> &x,
+ Vector<double> &y)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ y(i) = i+3.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+ y.compress ();
+
+ v.sadd (1.5, 2, w, 3, x, 4, y);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (y(i) == i+3., ExcInternalError());
+ Assert (v(i) == 1.5*i+2*(i+1.)+3*(i+2.)+4*(i+3), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_44.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ Vector<double> x (100);
+ Vector<double> y (100);
+ test (v,w,x,y);
+ }
+ 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
+//---------------------------- vector_45.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_45.cc ---------------------------
+
+
+// check Vector<double>::scale
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.scale (w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == i*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_45.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_46.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_46.cc ---------------------------
+
+
+// check Vector<double>::equ (s,V)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ }
+
+ v.compress ();
+ w.compress ();
+
+ v.equ (2, w);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (v(i) == 2*(i+1.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_46.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ test (v,w);
+ }
+ 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
+//---------------------------- vector_47.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_47.cc ---------------------------
+
+
+// check Vector<double>::equ (s,V,s,V)
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w,
+ Vector<double> &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.equ (2, w, 3, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (v(i) == 2*(i+1.)+3*(i+2.), ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_47.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ Vector<double> x (100);
+ test (v,w,x);
+ }
+ 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
+//---------------------------- vector_48.cc ---------------------------
+// vector_11.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.
+//
+//---------------------------- vector_48.cc ---------------------------
+
+
+// check Vector<double>::ratio
+
+#include "../tests.h"
+#include <lac/vector.h>
+#include <fstream>
+#include <iostream>
+#include <vector>
+
+
+void test (Vector<double> &v,
+ Vector<double> &w,
+ Vector<double> &x)
+{
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ v(i) = i;
+ w(i) = i+1.;
+ x(i) = i+2.;
+ }
+
+ v.compress ();
+ w.compress ();
+ x.compress ();
+
+ v.ratio (w, x);
+
+ // make sure we get the expected result
+ for (unsigned int i=0; i<v.size(); ++i)
+ {
+ Assert (w(i) == i+1., ExcInternalError());
+ Assert (x(i) == i+2., ExcInternalError());
+ Assert (std::fabs(v(i) - (i+1.)/(i+2.)) < 1e-14*v(i),
+ ExcInternalError());
+ }
+
+ deallog << "OK" << std::endl;
+}
+
+
+
+int main ()
+{
+ std::ofstream logfile("vector_48.output");
+ deallog.attach(logfile);
+ deallog.depth_console(0);
+
+ try
+ {
+ Vector<double> v (100);
+ Vector<double> w (100);
+ Vector<double> x (100);
+ test (v,w,x);
+ }
+ 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::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::8
+DEAL::OK
--- /dev/null
+
+DEAL::7.00000
+DEAL::OK
--- /dev/null
+
+DEAL::8.50000
+DEAL::OK
--- /dev/null
+
+DEAL::9.04157
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::116161. 116161. 0.00000
+DEAL::OK
--- /dev/null
+
+DEAL::116161. 116161. 0.00000
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::116161. 116161. 0.00000
+DEAL::OK
--- /dev/null
+
+DEAL::116161. 116161. 0.00000
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK
--- /dev/null
+
+DEAL::OK