]> https://gitweb.dealii.org/ - dealii.git/commitdiff
Add various std:: and other things to get the testsuite C++ compatible.
authorWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 22 May 2001 09:46:27 +0000 (09:46 +0000)
committerWolfgang Bangerth <bangerth@math.tamu.edu>
Tue, 22 May 2001 09:46:27 +0000 (09:46 +0000)
git-svn-id: https://svn.dealii.org/trunk@4689 0785d39b-7218-0410-832d-ea1e28bc413d

tests/base/auto_derivative_function.cc
tests/base/logtest.cc
tests/base/polynomial_test.cc
tests/base/quadrature_test.cc
tests/base/reference.cc
tests/base/tensor.cc
tests/base/timer.cc

index fa9f55dc2d6449b9283e23fa2976c5fdd5664fff..a8cbfdfd904783c5f2ee7a141838f6b0bd6e7554 100644 (file)
@@ -111,7 +111,7 @@ void ExactSinExp<dim>::vector_gradient (const Point<dim>       &p,
 
 int main(int, char)
 {
-  ofstream logfile("auto_derivative_function.output");
+  std::ofstream logfile("auto_derivative_function.output");
   logfile.precision(4);
   deallog.attach(logfile);
   deallog.depth_console(0);
@@ -131,7 +131,7 @@ int main(int, char)
     {
       formula=AutoDerivativeFunction<dim>::get_formula_of_order(order);
       auto_function.set_formula(formula);
-      deallog << "order=" << order << ",  formula=" << formula << endl;
+      deallog << "order=" << order << ",  formula=" << formula << std::endl;
       ConvergenceTable history;
       
       unsigned int factor=1;
index 0d8aa3db45da1ce7759e6c4bdf4337ed0355e6ab..73d9a04f0b4c7d31d3d08e450cae7deaeeb2393f 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
 #include <base/logstream.h>
 #include <fstream>
 
+
 int main()
 {
-  ofstream logfile("logtest.output");
+  std::ofstream logfile("logtest.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
 
index 572fe410084a876e48b819874b9654c7f09b5ceb..ba6bb47adec3f518175dba260bd2b72d09b065ff 100644 (file)
@@ -13,6 +13,7 @@
 
 #include <iostream>
 #include <fstream>
+#include <cmath>
 
 #include <base/logstream.h>
 #include <base/tensor_product_polynomials.h>
@@ -22,7 +23,7 @@
 bool equals_delta_ij(double value, unsigned int i, unsigned int j)
 {
   double eps=1e-14;
-  if ((i==j && fabs(value-1)<eps) || (i!=j && fabs(value)<eps))
+  if ((i==j && std::fabs(value-1)<eps) || (i!=j && std::fabs(value)<eps))
     return true;
   else
     return false;
@@ -37,12 +38,12 @@ void Q3_4th_shape_function_values_and_grads_dim2(
 
 int main(int, char)
 {
-  ofstream logfile("polynomial_test.output");
+  std::ofstream logfile("polynomial_test.output");
   logfile.precision(4);
   deallog.attach(logfile);
   deallog.depth_console(0);
   
-  vector<double> values(1);
+  std::vector<double> values(1);
   deallog << "LagrangeEquidistant polynoms:" << std::endl;
   for (unsigned int order=1; order<=4; ++order)
     {
@@ -81,12 +82,12 @@ int main(int, char)
 
   deallog << std::endl << "Test derivatives computed by the Horner scheme:" << std::endl;
   LagrangeEquidistant pol(4, 2);
-  vector<double> v_horner(6);
+  std::vector<double> v_horner(6);
   for (unsigned int i=0; i<=10; ++i)
     {
       double xi=i*0.1;
       deallog << "x=" << xi << ",    all derivatives: ";
-      vector<double> v_exact(6);
+      std::vector<double> v_exact(6);
       
       v_exact[0]=64.0*xi*xi*xi*xi-128.0*xi*xi*xi+76.0*xi*xi-12.0*xi;
       v_exact[1]=256.0*xi*xi*xi-384.0*xi*xi+152.0*xi-12.0;
@@ -102,7 +103,7 @@ int main(int, char)
        {
 //       deallog << "v_horner[i]=" << v_horner[i]
 //            << "   v_exact[i]=" << v_exact[i] << std::endl;
-         if (fabs(v_horner[i]-v_exact[i])>1e-12)
+         if (std::fabs(v_horner[i]-v_exact[i])>1e-12)
            ok=false;
        }
 
@@ -117,17 +118,17 @@ int main(int, char)
   if (true)
     {
       deallog << std::endl << "Derivatives of a polynomial of degree 0 (a constant function)." << std::endl;      
-      vector<double> a_const(1,1.);
+      std::vector<double> a_const(1,1.);
       const Polynomial<double> pol_const(a_const);
-      vector<double> exact_values(5,0.);
+      std::vector<double> exact_values(5,0.);
       exact_values[0]=1.;
-      vector<double> computed_values(5);
+      std::vector<double> computed_values(5);
 
       pol_const.value(0.24, computed_values);
       bool ok=true;
       for (unsigned int i=0; i<exact_values.size(); ++i)
        {
-         if (fabs(computed_values[i]-exact_values[i])>1e-15)
+         if (std::fabs(computed_values[i]-exact_values[i])>1e-15)
            ok=false;
        }
 
@@ -146,7 +147,7 @@ int main(int, char)
   deallog << "2D Example:" << std::endl;
   unsigned int p=3,
    n_tensor_pols=(p+1)*(p+1);
-  vector<Polynomial<double> > pols;
+  std::vector<Polynomial<double> > pols;
   
   for (unsigned int i=0; i<=p; ++i)
     pols.push_back(LagrangeEquidistant(p, i));
@@ -169,9 +170,9 @@ int main(int, char)
   Tensor<1,2> grad=tp_pol.compute_grad(i, point);
   Tensor<2,2> grad_grad=tp_pol.compute_grad_grad(i, point);
 
-  vector<double> vs(n_tensor_pols);
-  vector<Tensor<1,2> > grads(n_tensor_pols);
-  vector<Tensor<2,2> > grad_grads(n_tensor_pols);
+  std::vector<double> vs(n_tensor_pols);
+  std::vector<Tensor<1,2> > grads(n_tensor_pols);
+  std::vector<Tensor<2,2> > grad_grads(n_tensor_pols);
   tp_pol.compute(point, vs, grads, grad_grads);
 
 
index 50be5eece8a890be329bfe034274706b91835991..b6c7253c0cd1e95b50833285c606bf8f407cf5b7 100644 (file)
@@ -21,7 +21,7 @@
 
 template <int dim>
 void
-fill_vector (vector<Quadrature<dim> *>& quadratures)
+fill_vector (std::vector<Quadrature<dim> *>& quadratures)
 {
   quadratures.push_back (new QGauss2<dim>());
   quadratures.push_back (new QGauss3<dim>());
@@ -42,13 +42,13 @@ fill_vector (vector<Quadrature<dim> *>& quadratures)
 
 template <int dim>
 void
-check_cells (vector<Quadrature<dim>*>& quadratures)
+check_cells (std::vector<Quadrature<dim>*>& quadratures)
 {
   for (unsigned int n=0; n<quadratures.size(); ++n)
     {
       Quadrature<dim>& quadrature = *quadratures[n];
-      const vector<Point<dim> > &points=quadrature.get_points();
-      const vector<double> &weights=quadrature.get_weights();
+      const std::vector<Point<dim> > &points=quadrature.get_points();
+      const std::vector<double> &weights=quadrature.get_weights();
 
       deallog << "Quadrature no." << n
              << " (" << typeid(*quadratures[n]).name() << ")";
@@ -109,7 +109,7 @@ check_cells (vector<Quadrature<dim>*>& quadratures)
 
 template <int dim>
 void
-check_faces (vector<Quadrature<dim-1>*>& quadratures, bool sub)
+check_faces (const std::vector<Quadrature<dim-1>*>& quadratures, const bool sub)
 {
   if (sub)
     deallog.push("subfaces");
@@ -177,13 +177,13 @@ check_faces (vector<Quadrature<dim-1>*>& quadratures, bool sub)
 
 int main(int,char)
 {
-  ofstream logfile("quadrature_test.output");
+  std::ofstream logfile("quadrature_test.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
 
-  vector<Quadrature<1> *> q1;
-  vector<Quadrature<2> *> q2;
-  vector<Quadrature<3> *> q3;
+  std::vector<Quadrature<1> *> q1;
+  std::vector<Quadrature<2> *> q2;
+  std::vector<Quadrature<3> *> q3;
   fill_vector (q1);
   fill_vector (q2);
   fill_vector (q3);
index 3c84db90fed098e5177a0006423ffe87ad4207e4..1b54a605a58bccd6c479aea590cbb0cd1e1e865d 100644 (file)
@@ -44,10 +44,10 @@ public:
 
 int main()
 {
-  ofstream logfile("reference.output");
+  std::ofstream logfile("reference.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
-  cerr = logfile;
+  std::cerr = logfile;
   Test a("A");
   const Test b("B");
   SmartPointer<Test>       r=&a;
index 862152c1240168432f1bd9e36ca365b8bfd1f0c3..80ea42b3bfa2212fa5c045e26391aeaf38d687ef 100644 (file)
@@ -20,7 +20,7 @@
 
 int main ()
 {
-  ofstream logfile("tensor.output");
+  std::ofstream logfile("tensor.output");
   logfile.precision(3);
   deallog.attach(logfile);
   deallog.depth_console(0);
index 376e80b8a063759ec92c667cf9756f221758ae08..3ed423716ddb1e12865f06ab71ff63e0b99cc5ec 100644 (file)
@@ -2,7 +2,7 @@
 //    $Id$
 //    Version: $Name$
 //
-//    Copyright (C) 1998, 1999, 2000 by the deal.II authors
+//    Copyright (C) 1998, 1999, 2000, 2001 by the deal.II authors
 //
 //    This file is subject to QPL and may not be  distributed
 //    without copyright and license information. Please refer
@@ -15,6 +15,7 @@
 #include <base/timer.h>
 #include <base/logstream.h>
 #include <fstream>
+#include <cmath>
 
 // compute the ratio of two measurements and compare to
 // the expected value.
@@ -22,7 +23,7 @@
 void compare (double t1, double t2, double ratio)
 {
   double r = t2/t1;
-  double d = fabs(r-ratio) / ratio;
+  double d = std::fabs(r-ratio) / ratio;
 
                                   // relative error < 10%?
   if (d <= .1)
@@ -50,7 +51,7 @@ void burn (unsigned int n)
 
 int main ()
 {
-  ofstream logfile("timer.output");
+  std::ofstream logfile("timer.output");
   deallog.attach(logfile);
   deallog.depth_console(0);
 

In the beginning the Universe was created. This has made a lot of people very angry and has been widely regarded as a bad move.

Douglas Adams


Typeset in Trocchi and Trocchi Bold Sans Serif.