From 161b389473ef5e3bfcf73543de4c86ea6a8415dd Mon Sep 17 00:00:00 2001 From: wolf Date: Fri, 6 Jul 2001 09:03:59 +0000 Subject: [PATCH] Fix some issues with cxx. git-svn-id: https://svn.dealii.org/trunk@4826 0785d39b-7218-0410-832d-ea1e28bc413d --- tests/base/auto_derivative_function.cc | 16 +++++++-------- tests/base/polynomial_test.cc | 7 ++++++- tests/base/quadrature_test.cc | 28 +++++++++++++------------- 3 files changed, 28 insertions(+), 23 deletions(-) diff --git a/tests/base/auto_derivative_function.cc b/tests/base/auto_derivative_function.cc index a8cbfdfd90..fbdb479554 100644 --- a/tests/base/auto_derivative_function.cc +++ b/tests/base/auto_derivative_function.cc @@ -55,7 +55,7 @@ template double AutoSinExp::value (const Point &p, const unsigned int) const { - return sin(2*p(0))*exp(3*p(1)); + return std::sin(2*p(0))*std::exp(3*p(1)); } @@ -92,8 +92,8 @@ Tensor<1,dim> ExactSinExp::gradient (const Point &p, const unsigned int) const { Tensor<1,dim> grad; - grad[0]=2*cos(2*p(0))*exp(3*p(1)); - grad[1]=3*sin(2*p(0))*exp(3*p(1)); + grad[0]=2*std::cos(2*p(0))*std::exp(3*p(1)); + grad[1]=3*std::sin(2*p(0))*std::exp(3*p(1)); return grad; } @@ -109,7 +109,7 @@ void ExactSinExp::vector_gradient (const Point &p, } -int main(int, char) +int main() { std::ofstream logfile("auto_derivative_function.output"); logfile.precision(4); @@ -145,7 +145,7 @@ int main(int, char) // Test of gradient function Tensor<1,dim> a_grad=auto_function.gradient(p); a_grad-=u_grad; - double value=sqrt(a_grad*a_grad); + double value=std::sqrt(a_grad*a_grad); history.add_value("grad", value); history.set_scientific("grad", true); history.set_precision("grad", 2); @@ -155,7 +155,7 @@ int main(int, char) std::vector > a_grads(1); auto_function.gradient_list(ps, a_grads); a_grads[0]-=u_grad; - value=sqrt(a_grads[0]*a_grads[0]); + value=std::sqrt(a_grads[0]*a_grads[0]); history.add_value("grads[0]", value); history.set_scientific("grads[0]", true); history.set_precision("grads[0]", 2); @@ -165,7 +165,7 @@ int main(int, char) std::vector > a_vgrad(2); auto_function.vector_gradient(p, a_vgrad); a_vgrad[1]-=u_grad; - value=sqrt(a_vgrad[1]*a_vgrad[1]); + value=std::sqrt(a_vgrad[1]*a_vgrad[1]); history.add_value("vgrad[1]", value); history.set_scientific("vgrad[1]", true); history.set_precision("vgrad[1]", 2); @@ -177,7 +177,7 @@ int main(int, char) a_vgrads(1, std::vector > (2)); auto_function.vector_gradient_list(ps, a_vgrads); a_vgrads[0][1]-=u_grad; - value=sqrt(a_vgrads[0][1]*a_vgrads[0][1]); + value=std::sqrt(a_vgrads[0][1]*a_vgrads[0][1]); history.add_value("vgrads[1]", value); history.set_scientific("vgrads[1]", true); history.set_precision("vgrads[1]", 2); diff --git a/tests/base/polynomial_test.cc b/tests/base/polynomial_test.cc index ba6bb47ade..841a5aea7b 100644 --- a/tests/base/polynomial_test.cc +++ b/tests/base/polynomial_test.cc @@ -19,6 +19,11 @@ #include +extern "C" +void abort() +{} + + bool equals_delta_ij(double value, unsigned int i, unsigned int j) { @@ -36,7 +41,7 @@ void Q3_4th_shape_function_values_and_grads_dim2( -int main(int, char) +int main() { std::ofstream logfile("polynomial_test.output"); logfile.precision(4); diff --git a/tests/base/quadrature_test.cc b/tests/base/quadrature_test.cc index 848aed80f0..c7d3d887ad 100644 --- a/tests/base/quadrature_test.cc +++ b/tests/base/quadrature_test.cc @@ -71,18 +71,18 @@ check_cells (std::vector*>& quadratures) switch (dim) { case 3: - f *= pow(points[x](2), i); + f *= std::pow(static_cast(points[x](2)), i*1.0); case 2: - f *= pow(points[x](1), i); + f *= std::pow(static_cast(points[x](1)), i*1.0); case 1: - f *= pow(points[x](0), i); + f *= std::pow(static_cast(points[x](0)), i*1.0); } quadrature_int+=f*weights[x]; } // the exact integral is 1/(i+1) - exact_int=1./pow(i+1,dim); - err = fabs(quadrature_int-exact_int); + exact_int=1./std::pow(static_cast(i+1),dim); + err = std::fabs(quadrature_int-exact_int); } while (err<1e-15); // Uncomment here for testing @@ -144,11 +144,11 @@ check_faces (const std::vector*>& quadratures, const bool sub) switch (dim) { case 3: - f *= pow(points[x](2), i); + f *= std::pow(points[x](2), i*1.0); case 2: - f *= pow(points[x](1), i); + f *= std::pow(points[x](1), i*1.0); case 1: - f *= pow(points[x](0), i); + f *= std::pow(points[x](0), i*1.0); } quadrature_int+=f*weights[x]; } @@ -165,7 +165,7 @@ check_faces (const std::vector*>& quadratures, const bool sub) break; } - err = fabs(quadrature_int-exact_int); + err = std::fabs(quadrature_int-exact_int); } while (err<5e-15); // Uncomment here for testing @@ -175,7 +175,7 @@ check_faces (const std::vector*>& quadratures, const bool sub) deallog.pop(); } -int main(int,char) +int main() { std::ofstream logfile("quadrature_test.output"); deallog.attach(logfile); @@ -194,14 +194,14 @@ int main(int,char) deallog.push("2d"); check_cells(q2); - check_faces(q1,false); - check_faces(q1,true); + check_faces<2>(q1,false); + check_faces<2>(q1,true); deallog.pop(); deallog.push("3d"); check_cells(q3); - check_faces(q2,false); - check_faces(q2,true); + check_faces<3>(q2,false); + check_faces<3>(q2,true); deallog.pop(); // delete objects again to avoid -- 2.39.5