From 95588100f2fc8faa68f1fe2867254eda91d2623b Mon Sep 17 00:00:00 2001 From: Denis Davydov Date: Thu, 13 Oct 2016 10:50:57 +0200 Subject: [PATCH] add a quick test for GSL --- tests/quick_tests/CMakeLists.txt | 5 +++ tests/quick_tests/gsl.cc | 55 ++++++++++++++++++++++++++++++++ 2 files changed, 60 insertions(+) create mode 100644 tests/quick_tests/gsl.cc diff --git a/tests/quick_tests/CMakeLists.txt b/tests/quick_tests/CMakeLists.txt index 6338fa0df9..97bae28fca 100644 --- a/tests/quick_tests/CMakeLists.txt +++ b/tests/quick_tests/CMakeLists.txt @@ -131,6 +131,11 @@ IF (DEAL_II_WITH_UMFPACK) make_quicktest("umfpack" ${_mybuild} "") ENDIF() +# Test GSL +IF (DEAL_II_WITH_GSL) + make_quicktest("gsl" ${_mybuild} "") +ENDIF() + # A custom test target: diff --git a/tests/quick_tests/gsl.cc b/tests/quick_tests/gsl.cc new file mode 100644 index 0000000000..a9d8e19c9f --- /dev/null +++ b/tests/quick_tests/gsl.cc @@ -0,0 +1,55 @@ +// --------------------------------------------------------------------- +// +// Copyright (C) 2016 by the deal.II authors +// +// This file is part of the deal.II library. +// +// The deal.II library is free software; you can use it, redistribute +// it, and/or modify it under the terms of the GNU Lesser General +// Public License as published by the Free Software Foundation; either +// version 2.1 of the License, or (at your option) any later version. +// The full text of the license can be found in the file LICENSE at +// the top level of the deal.II distribution. +// +// --------------------------------------------------------------------- + + +// Test GSL by running CSpline. Copy-paste of /base/functions_cspline +// take example from https://www.gnu.org/software/gsl/manual/html_node/Interpolation-Example-programs.html + +#include "../tests.h" +#include +#include + +template +void check() +{ + const unsigned int n_points = 10; + std::vector x(n_points), y(n_points); + for (unsigned int i = 0; i < n_points; i++) + { + x[i] = i + 0.5 * std::sin (i); + y[i] = i + std::cos (i * i); + } + + std::vector y_dealii; + Functions::CSpline cspline(x,y); + for (double xi = x[0]; xi <= x.back(); xi += 0.01) + { + const double yi = cspline.value(Point(xi)); + y_dealii.push_back(yi); + } + + deallog << "Ok"<< std::endl; +} + +int main() +{ + std::string logname = "output"; + std::ofstream logfile(logname.c_str()); + deallog.attach(logfile); + deallog.threshold_double(1.e-10); + + check<1>(); +} + -- 2.39.5