Commit 39a1a3a7 authored by Michael Tesch's avatar Michael Tesch
Browse files

update README with better cmake instructions

limit appveyor git clone depth, always output ctest failure
tests for the specialized functions
parent 42c84ec2
Loading
Loading
Loading
Loading
+4 −0
Original line number Diff line number Diff line
version: 0.2.{build}
clone_folder: c:\projects\cppduals
clone_depth: 3

image:
#- Visual Studio 2013
@@ -10,6 +11,9 @@ configuration:
- Release
#- Debug # someone with a debugger please investigate this :)

# Do not build feature branch with open Pull Requests
skip_branch_with_pr: true

# skip unsupported combinations
init:
- echo %APPVEYOR_BUILD_WORKER_IMAGE%
+4 −6
Original line number Diff line number Diff line
#image: ubuntu:19.04
image: fedora:30

variables:
  GIT_DEPTH: 3
  CTEST_OUTPUT_ON_FAILURE: y

stages:
- build
- test
@@ -31,8 +35,6 @@ build:

test:
  stage: test
  variables:
    CTEST_OUTPUT_ON_FAILURE: y
  script:
  - cmake --build build --target test
  - cmake --build build-latest --target test
@@ -40,8 +42,6 @@ test:
  - build

cover:
  variables:
    CTEST_OUTPUT_ON_FAILURE: y
  script:
  - cmake -Bbuild-cov -H. -DCODE_COVERAGE=ON -DCPPDUALS_TESTING=ON
  - cmake --build build-cov --target cov
@@ -55,8 +55,6 @@ cover:
  - merge_requests

pages:
  variables:
    CTEST_OUTPUT_ON_FAILURE: y
  script:
  - cmake -Bbuild -H. -DCODE_COVERAGE=ON -DCPPDUALS_TESTING=ON
  - cmake --build build --target docs
+4 −2
Original line number Diff line number Diff line
@@ -87,13 +87,15 @@ cmake --build buildx --target install
Or, using cmake's `ExternalProject_Add()`

```cmake
  set (CPPDUALS_SHA d62ba870876d93cb29acd153d572cff62bbb6afd)
  set (CPPDUALS_VER 0.1.2)
  set (CPPDUALS_MD5 48d9276482e5f07a768875ef692d14cd)
  ExternalProject_Add (cppdualsX
    PREFIX cppdualsX
    URL https://gitlab.com/tesch1/cppduals/-/archive/v${CPPDUALS_VER}/cppduals-v${CPPDUALS_VER}.tar.bz2
    URL_HASH MD5=${CPPDUALS_MD5}
    CONFIGURE_COMMAND ""
    BUILD_COMMAND ""
    INSTALL_COMMAND ""
    URL https://gitlab.com/api/v4/projects/tesch1%2Fcppduals/repository/archive.tbz2?sha=${CPPDUALS_SHA}
    )
  ExternalProject_Get_Property (cppdualsX source_dir)
  include_directories (${source_dir}/)
+23 −2
Original line number Diff line number Diff line
@@ -35,8 +35,8 @@ typedef std::complex<double> complexd;
    for (T x : __VA_ARGS__) {                                           \
      T prec = 100 * std::sqrt(std::numeric_limits<T>::epsilon());      \
      T dd = dpart(F(x + dual<T>(0,1)));                                \
      T dx = std::numeric_limits<T>::epsilon() * (T)1000000;            \
      /*T dx2 = T(1)/ (1ull << (std::numeric_limits<T>::digits / 3));*/ \
      /*T dx = std::numeric_limits<T>::epsilon() * (T)1000000;      */  \
      T dx = T(1)/ (1ull << (std::numeric_limits<T>::digits / 3));      \
      T fd = (F(x + dx) - F(x - dx)) / (2*dx);                          \
      EXPECT_CNEAR(dd, fd, prec * std::abs(std::max(std::max(dd,fd),T(1)))) \
        << "dd=" << dd << " fd=" << fd << " x=" << x << " dx=" << dx;   \
@@ -71,6 +71,27 @@ FD_CHECK(double, erfc, {-1,0,1})
FD_CHECK(double, tgamma, {1.,0.5,10.})
FD_CHECK(double, lgamma, {-1.1, 0.5, 1.1, 2.})

// check that functions with poles in their derivatives dont generate
// NaNs at the poles if dpart==0.
#define DZERO_CHECK(F, DZ)                      \
  TEST(zero_##F, DZ) {                          \
    dual<double> d(DZ,0);                       \
    EXPECT_TRUE(std::isfinite(F(d).dpart()));   \
  }

DZERO_CHECK(log, 0)
DZERO_CHECK(sqrt, 0)
DZERO_CHECK(cbrt, 0)
DZERO_CHECK(asin, 1)
DZERO_CHECK(acos, 1)
//DZERO_CHECK(atan, i)
//DZERO_CHECK(atan2, i)

// These dont really cause d/dt = 0, but do a partial check and
// increase code coverage.
DZERO_CHECK(tgamma, 0)
DZERO_CHECK(lgamma, 0)

TEST(func, tgamma) {
  duald x = 10 + 4_e;
  //EXPECT_EQ(tgamma(x).rpart(), 362880); "interestingly", compiling without optimization (-O0) causes this to fail