LCOV - code coverage report
Current view: top level - test - threetermTests.cpp (source / functions) Hit Total Coverage
Test: coverage.info.cleaned Lines: 236 236 100.0 %
Date: 2020-12-14 08:13:14 Functions: 42 42 100.0 %

          Line data    Source code
       1             : #include <gmock/gmock.h>
       2             : #include <gtest/gtest.h>
       3             : #include <cfloat>
       4             : #include <cmath>
       5             : #include <limits>
       6             : 
       7             : #include "threeterm.hpp"
       8             : 
       9             : #define epsilon DBL_EPSILON
      10             : using namespace testing;
      11             : using namespace std;
      12             : 
      13           2 : TEST(ThreeTermAnalysisOf,
      14             :      TaylorSeriesAtNegativeOneRealPoleAtOneWithScalingTenthAlphaOne)
      15             : {
      16             :   // t =-1.0;
      17             :   // x[0] = 1.0/(1.0-t);
      18             : 
      19           1 :   double a{1.0};
      20           1 :   double time{-1.0};
      21           1 :   double scale{0.1};
      22             :   vector<double> coeffs{0.5,
      23             :                         0.025,
      24             :                         0.00125,
      25             :                         6.25e-05,
      26             :                         3.125e-06,
      27             :                         1.5625e-07,
      28             :                         7.8125e-09,
      29             :                         3.90625e-10,
      30             :                         1.953125e-11,
      31             :                         9.765625e-13,
      32             :                         4.8828125e-14,
      33             :                         2.44140625e-15,
      34             :                         1.220703125e-16,
      35             :                         6.103515625e-18,
      36             :                         3.0517578125e-19,
      37             :                         1.52587890625e-20,
      38             :                         7.62939453125001e-22,
      39             :                         3.814697265625e-23,
      40             :                         1.9073486328125e-24,
      41             :                         9.53674316406251e-26,
      42             :                         4.76837158203126e-27,
      43             :                         2.38418579101563e-28,
      44             :                         1.19209289550781e-29,
      45             :                         5.96046447753907e-31,
      46             :                         2.98023223876954e-32,
      47             :                         1.49011611938477e-33,
      48             :                         7.45058059692384e-35,
      49             :                         3.72529029846192e-36,
      50             :                         1.86264514923096e-37,
      51           2 :                         9.3132257461548e-39};
      52           1 :   double rc{0.0}, order{0.0};
      53             : 
      54           1 :   double err = threeterm(coeffs, scale, rc, order);
      55             : 
      56           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
      57           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 9.68115e-14));
      58           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.1887e-12));
      59           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
      60           1 : }
      61             : 
      62           2 : TEST(ThreeTermAnalysisOf,
      63             :      TaylorSeriesAtZeroOneRealPoleAtOneWithScalingTenthAlphaOne)
      64             : {
      65             :   // t = 0.0;
      66             :   // x[0] = 1.0/(1.0-t);
      67             : 
      68           1 :   double a{1.0};
      69           1 :   double time{0.0};
      70           1 :   double scale{0.1};
      71             :   vector<double> coeffs{1,     0.1,   0.01,  0.001, 0.0001, 1e-05, 1e-06, 1e-07,
      72             :                         1e-08, 1e-09, 1e-10, 1e-11, 1e-12,  1e-13, 1e-14, 1e-15,
      73             :                         1e-16, 1e-17, 1e-18, 1e-19, 1e-20,  1e-21, 1e-22, 1e-23,
      74           2 :                         1e-24, 1e-25, 1e-26, 1e-27, 1e-28,  1e-29};
      75           1 :   double rc{0.0}, order{0.0};
      76             : 
      77           1 :   double err = threeterm(coeffs, scale, rc, order);
      78             : 
      79           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
      80           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 4.44090e-16));
      81           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.35448e-14));
      82           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
      83           1 : }
      84             : 
      85           2 : TEST(ThreeTermAnalysisOf,
      86             :      TaylorSeriesAtPTNineOneRealPoleAtOneWithScalingTenthAlphaOne)
      87             : {
      88             :   // t = 0.9;
      89             :   // x[0] = 1.0/(1.0-t);
      90             : 
      91           1 :   double a{1.0};
      92           1 :   double time{0.9};
      93           1 :   double scale{0.1};
      94             :   vector<double> coeffs{10,
      95             :                         10,
      96             :                         10,
      97             :                         10,
      98             :                         10,
      99             :                         10,
     100             :                         10,
     101             :                         10,
     102             :                         10,
     103             :                         10,
     104             :                         10,
     105             :                         10,
     106             :                         10,
     107             :                         10,
     108             :                         10,
     109             :                         10,
     110             :                         10,
     111             :                         10.0000000000001,
     112             :                         10.0000000000001,
     113             :                         10.0000000000001,
     114             :                         10.0000000000001,
     115             :                         10.0000000000001,
     116             :                         10.0000000000001,
     117             :                         10.0000000000001,
     118             :                         10.0000000000001,
     119             :                         10.0000000000001,
     120             :                         10.0000000000001,
     121             :                         10.0000000000001,
     122             :                         10.0000000000001,
     123           2 :                         10.0000000000001};
     124           1 :   double rc{0.0}, order{0.0};
     125             : 
     126           1 :   double err = threeterm(coeffs, scale, rc, order);
     127             : 
     128           1 :   EXPECT_THAT(err, DoubleNear(0.0, 8.52652e-14));
     129           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 8.52652e-14));
     130           1 :   EXPECT_THAT(order, DoubleNear(1.0, 2.93099e-14));
     131           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     132           1 : }
     133             : 
     134           2 : TEST(ThreeTermAnalysisOf,
     135             :      TaylorSeriesAtOnePT0001RealPoleAtOneWithScalingTenthAlphaOne)
     136             : {
     137             :   // t = 1.0001;
     138             :   // x[0] = 1.0/(1.0-t);
     139             : 
     140           1 :   double a{1.0};
     141           1 :   double time{1.0001};
     142           1 :   double scale{0.1};
     143             :   vector<double> coeffs{
     144             :       -10000.0000000011,     10000000.0000022,      -10000000000.0033,
     145             :       10000000000004.4,      -1.00000000000055e+16, 1.00000000000066e+19,
     146             :       -1.00000000000077e+22, 1.00000000000088e+25,  -1.00000000000099e+28,
     147             :       1.0000000000011e+31,   -1.00000000000121e+34, 1.00000000000132e+37,
     148             :       -1.00000000000143e+40, 1.00000000000154e+43,  -1.00000000000165e+46,
     149             :       1.00000000000176e+49,  -1.00000000000187e+52, 1.00000000000198e+55,
     150             :       -1.00000000000209e+58, 1.0000000000022e+61,   -1.00000000000231e+64,
     151             :       1.00000000000242e+67,  -1.00000000000253e+70, 1.00000000000264e+73,
     152             :       -1.00000000000275e+76, 1.00000000000286e+79,  -1.00000000000297e+82,
     153           2 :       1.00000000000308e+85,  -1.00000000000319e+88, 1.00000000000331e+91};
     154           1 :   double rc{0.0}, order{0.0};
     155             : 
     156           1 :   double err = threeterm(coeffs, scale, rc, order);
     157             : 
     158           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.7213e+58));
     159           1 :   EXPECT_THAT(rc, DoubleNear(a - time, epsilon));
     160           1 :   EXPECT_THAT(order, DoubleNear(1.0, 8.03569e-12));
     161           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     162           1 : }
     163             : 
     164           2 : TEST(ThreeTermAnalysisOf,
     165             :      TaylorSeriesAtOnePT9RealPoleAtOneWithScalingTenthAlphaOne)
     166             : {
     167             :   // t = 1.9;
     168             :   // x[0] = 1.0/(1.0-t);
     169             : 
     170           1 :   double a{1.0};
     171           1 :   double time{1.9};
     172           1 :   double scale{0.1};
     173             :   vector<double> coeffs{
     174             :       -1.11111111111111,     0.123456790123457,     -0.0137174211248285,
     175             :       0.00152415790275873,   -0.000169350878084303, 1.88167642315892e-05,
     176             :       -2.09075158128769e-06, 2.32305731254188e-07,  -2.5811747917132e-08,
     177             :       2.86797199079245e-09,  -3.18663554532494e-10, 3.54070616147216e-11,
     178             :       -3.93411795719128e-12, 4.37124217465698e-13,  -4.85693574961887e-14,
     179             :       5.3965952773543e-15,   -5.99621697483812e-16, 6.66246330537568e-17,
     180             :       -7.40273700597298e-18, 8.22526333996998e-19,  -9.13918148885554e-20,
     181             :       1.01546460987284e-20,  -1.12829401096982e-21, 1.25366001218869e-22,
     182             :       -1.39295556909854e-23, 1.54772841010949e-24,  -1.71969823345499e-25,
     183           2 :       1.91077581494999e-26,  -2.12308423883332e-27, 2.35898248759258e-28};
     184           1 :   double rc{0.0}, order{0.0};
     185             : 
     186           1 :   double err = threeterm(coeffs, scale, rc, order);
     187             : 
     188           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     189           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 8.54872e-14));
     190           1 :   EXPECT_THAT(order, DoubleNear(1.0, 2.19869e-12));
     191           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     192           1 : }
     193             : 
     194           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtThreePoleAtOneWithScalingTenthAlphaOne)
     195             : {
     196             :   // t = 3.0;
     197             :   // x[0] = 1.0/(1.0-t);
     198             : 
     199           1 :   double a{1.0};
     200           1 :   double time{3.0};
     201           1 :   double scale{0.1};
     202             :   vector<double> coeffs{-0.5,
     203             :                         0.025,
     204             :                         -0.00125,
     205             :                         6.25e-05,
     206             :                         -3.125e-06,
     207             :                         1.5625e-07,
     208             :                         -7.8125e-09,
     209             :                         3.90625e-10,
     210             :                         -1.953125e-11,
     211             :                         9.765625e-13,
     212             :                         -4.8828125e-14,
     213             :                         2.44140625e-15,
     214             :                         -1.220703125e-16,
     215             :                         6.103515625e-18,
     216             :                         -3.0517578125e-19,
     217             :                         1.52587890625e-20,
     218             :                         -7.62939453125001e-22,
     219             :                         3.814697265625e-23,
     220             :                         -1.9073486328125e-24,
     221             :                         9.53674316406251e-26,
     222             :                         -4.76837158203126e-27,
     223             :                         2.38418579101563e-28,
     224             :                         -1.19209289550781e-29,
     225             :                         5.96046447753907e-31,
     226             :                         -2.98023223876954e-32,
     227             :                         1.49011611938477e-33,
     228             :                         -7.45058059692384e-35,
     229             :                         3.72529029846192e-36,
     230             :                         -1.86264514923096e-37,
     231           2 :                         9.3132257461548e-39};
     232           1 :   double rc{0.0}, order{0.0};
     233             : 
     234           1 :   double err = threeterm(coeffs, scale, rc, order);
     235             : 
     236           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     237           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 9.68115e-14));
     238           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.1887e-12));
     239           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     240           1 : }
     241             : 
     242           2 : TEST(ThreeTermAnalysisOf,
     243             :      TaylorSeriesAtNegativeOneRealPoleAtOneWithScalingOneAlphaOne)
     244             : {
     245             :   // t =-1.0;
     246             :   // x[0] = 1.0/(1.0-t);
     247             : 
     248           1 :   double a{1.0};
     249           1 :   double time{-1.0};
     250           1 :   double scale{1.0};
     251             :   vector<double> coeffs{
     252             :       5.000000000000000e-01, 2.500000000000000e-01, 1.250000000000000e-01,
     253             :       6.250000000000000e-02, 3.125000000000000e-02, 1.562500000000000e-02,
     254             :       7.812500000000000e-03, 3.906250000000000e-03, 1.953125000000000e-03,
     255             :       9.765625000000000e-04, 4.882812500000000e-04, 2.441406250000000e-04,
     256             :       1.220703125000000e-04, 6.103515625000000e-05, 3.051757812500000e-05,
     257             :       1.525878906250000e-05, 7.629394531250000e-06, 3.814697265625000e-06,
     258             :       1.907348632812500e-06, 9.536743164062500e-07, 4.768371582031250e-07,
     259             :       2.384185791015625e-07, 1.192092895507813e-07, 5.960464477539063e-08,
     260             :       2.980232238769531e-08, 1.490116119384766e-08, 7.450580596923828e-09,
     261           2 :       3.725290298461914e-09, 1.862645149230957e-09, 9.313225746154785e-10};
     262           1 :   double rc{0.0}, order{0.0};
     263             : 
     264           1 :   double err = threeterm(coeffs, scale, rc, order);
     265             : 
     266           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     267           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 1.06582e-14));
     268           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.33005e-13));
     269           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     270           1 : }
     271             : 
     272           2 : TEST(ThreeTermAnalysisOf,
     273             :      TaylorSeriesAtZeroOneRealPoleAtOneWithScalingOneAlphaOne)
     274             : {
     275             :   // t = 0.0;
     276             :   // x[0] = 1.0/(1.0-t);
     277             : 
     278           1 :   double a{1.0};
     279           1 :   double time{0.0};
     280           1 :   double scale{1.0};
     281             :   vector<double> coeffs{1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1,
     282           2 :                         1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1};
     283           1 :   double rc{0.0}, order{0.0};
     284             : 
     285           1 :   double err = threeterm(coeffs, scale, rc, order);
     286             : 
     287           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.06582e-14));
     288           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 6.66134e-16));
     289           1 :   EXPECT_THAT(order, DoubleNear(1.0, 2.4758e-14));
     290           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     291           1 : }
     292             : 
     293           2 : TEST(ThreeTermAnalysisOf,
     294             :      TaylorSeriesAtPTNineOneRealPoleAtOneWithScalingOneAlphaOne)
     295             : {
     296             :   // t = 0.9;
     297             :   // x[0] = 1.0/(1.0-t);
     298             : 
     299           1 :   double a{1.0};
     300           1 :   double time{0.9};
     301           1 :   double scale{1.0};
     302             :   vector<double> coeffs{
     303             :       1.000000000000000e+01, 1.000000000000000e+02, 1.000000000000001e+03,
     304             :       1.000000000000001e+04, 1.000000000000001e+05, 1.000000000000001e+06,
     305             :       1.000000000000002e+07, 1.000000000000002e+08, 1.000000000000002e+09,
     306             :       1.000000000000002e+10, 1.000000000000002e+11, 1.000000000000003e+12,
     307             :       1.000000000000003e+13, 1.000000000000003e+14, 1.000000000000003e+15,
     308             :       1.000000000000004e+16, 1.000000000000004e+17, 1.000000000000004e+18,
     309             :       1.000000000000004e+19, 1.000000000000005e+20, 1.000000000000005e+21,
     310             :       1.000000000000005e+22, 1.000000000000005e+23, 1.000000000000005e+24,
     311             :       1.000000000000006e+25, 1.000000000000006e+26, 1.000000000000006e+27,
     312           2 :       1.000000000000006e+28, 1.000000000000007e+29, 1.000000000000007e+30};
     313           1 :   double rc{0.0}, order{0.0};
     314             : 
     315           1 :   double err = threeterm(coeffs, scale, rc, order);
     316             : 
     317           1 :   EXPECT_THAT(err, DoubleNear(0.0, 2.25486e+10));
     318           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 2.98373e-15));
     319           1 :   EXPECT_THAT(order, DoubleNear(1.0, 8.77743e-13));
     320           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     321           1 : }
     322             : 
     323           2 : TEST(ThreeTermAnalysisOf,
     324             :      TaylorSeriesAtOnePT0001RealPoleAtOneWithScalingOneAlphaOne)
     325             : {
     326             :   // t = 1.0001;
     327             :   // x[0] = 1.0/(1.0-t);
     328             : 
     329           1 :   double a{1.0};
     330           1 :   double time{1.0001};
     331           1 :   double scale{1.0};
     332             :   vector<double> coeffs{
     333             :       -1.000000000000110e+04,  1.000000000000220e+08,   -1.000000000000330e+12,
     334             :       1.000000000000440e+16,   -1.000000000000551e+20,  1.000000000000661e+24,
     335             :       -1.000000000000771e+28,  1.000000000000881e+32,   -1.000000000000991e+36,
     336             :       1.000000000001101e+40,   -1.000000000001211e+44,  1.000000000001321e+48,
     337             :       -1.000000000001431e+52,  1.000000000001542e+56,   -1.000000000001652e+60,
     338             :       1.000000000001762e+64,   -1.000000000001872e+68,  1.000000000001982e+72,
     339             :       -1.000000000002092e+76,  1.000000000002202e+80,   -1.000000000002312e+84,
     340             :       1.000000000002422e+88,   -1.000000000002533e+92,  1.000000000002643e+96,
     341             :       -1.000000000002753e+100, 1.000000000002863e+104,  -1.000000000002973e+108,
     342           2 :       1.000000000003083e+112,  -1.000000000003193e+116, 1.000000000003303e+120};
     343           1 :   double rc{0.0}, order{0.0};
     344             : 
     345           1 :   double err = threeterm(coeffs, scale, rc, order);
     346             : 
     347           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.85268e+78));
     348           1 :   EXPECT_THAT(rc, DoubleNear(a - time, epsilon));
     349           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.5100e-14));
     350           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     351           1 : }
     352             : 
     353           2 : TEST(ThreeTermAnalysisOf,
     354             :      TaylorSeriesAtOnePT9RealPoleAtOneWithScalingOneAlphaOne)
     355             : {
     356             :   // t = 1.9;
     357             :   // x[0] = 1.0/(1.0-t);
     358             : 
     359           1 :   double a{1.0};
     360           1 :   double time{1.9};
     361           1 :   double scale{1.0};
     362             :   vector<double> coeffs{
     363             :       -1.111111111111111e+00, 1.234567901234568e+00,  -1.371742112482853e+00,
     364             :       1.524157902758726e+00,  -1.693508780843029e+00, 1.881676423158922e+00,
     365             :       -2.090751581287691e+00, 2.323057312541879e+00,  -2.581174791713199e+00,
     366             :       2.867971990792444e+00,  -3.186635545324938e+00, 3.540706161472154e+00,
     367             :       -3.934117957191282e+00, 4.371242174656981e+00,  -4.856935749618868e+00,
     368             :       5.396595277354298e+00,  -5.996216974838109e+00, 6.662463305375677e+00,
     369             :       -7.402737005972976e+00, 8.225263339969974e+00,  -9.139181488855527e+00,
     370             :       1.015464609872837e+01,  -1.128294010969818e+01, 1.253660012188687e+01,
     371             :       -1.392955569098542e+01, 1.547728410109491e+01,  -1.719698233454990e+01,
     372           2 :       1.910775814949989e+01,  -2.123084238833321e+01, 2.358982487592579e+01};
     373           1 :   double rc{0.0}, order{0.0};
     374             : 
     375           1 :   double err = threeterm(coeffs, scale, rc, order);
     376             : 
     377           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.98952e-13));
     378           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 9.99201e-16));
     379           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.77636e-14));
     380           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     381           1 : }
     382             : 
     383           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtThreePoleAtOneWithScalingOneAlphaOne)
     384             : {
     385             :   // t = 3.0;
     386             :   // x[0] = 1.0/(1.0-t);
     387             : 
     388           1 :   double a{1.0};
     389           1 :   double time{3.0};
     390           1 :   double scale{1.0};
     391             :   vector<double> coeffs{
     392             :       -5.000000000000000e-01, 2.500000000000000e-01,  -1.250000000000000e-01,
     393             :       6.250000000000000e-02,  -3.125000000000000e-02, 1.562500000000000e-02,
     394             :       -7.812500000000000e-03, 3.906250000000000e-03,  -1.953125000000000e-03,
     395             :       9.765625000000000e-04,  -4.882812500000000e-04, 2.441406250000000e-04,
     396             :       -1.220703125000000e-04, 6.103515625000000e-05,  -3.051757812500000e-05,
     397             :       1.525878906250000e-05,  -7.629394531250000e-06, 3.814697265625000e-06,
     398             :       -1.907348632812500e-06, 9.536743164062500e-07,  -4.768371582031250e-07,
     399             :       2.384185791015625e-07,  -1.192092895507813e-07, 5.960464477539063e-08,
     400             :       -2.980232238769531e-08, 1.490116119384766e-08,  -7.450580596923828e-09,
     401           2 :       3.725290298461914e-09,  -1.862645149230957e-09, 9.313225746154785e-10};
     402           1 :   double rc{0.0}, order{0.0};
     403             : 
     404           1 :   double err = threeterm(coeffs, scale, rc, order);
     405             : 
     406           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     407           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 1.06582e-14));
     408           1 :   EXPECT_THAT(order, DoubleNear(1.0, 1.33005e-13));
     409           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     410           1 : }
     411             : 
     412             : // Requires TOL=1e-1
     413           2 : TEST(ThreeTermAnalysisOf,
     414             :      TaylorSeriesAtNegativeOnePoleAtOneWithScalingTenthAlphaTwo)
     415             : {
     416             :   // t =-1.0;
     417             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     418             : 
     419           1 :   double a{1.0};
     420           1 :   double time{-1.0};
     421           1 :   double scale{0.1};
     422             :   vector<double> coeffs{0.25,
     423             :                         0.025,
     424             :                         0.001875,
     425             :                         0.000125,
     426             :                         7.8125e-06,
     427             :                         4.6875e-07,
     428             :                         2.734375e-08,
     429             :                         1.5625e-09,
     430             :                         8.78906250000001e-11,
     431             :                         4.8828125e-12,
     432             :                         2.685546875e-13,
     433             :                         1.46484375e-14,
     434             :                         7.9345703125e-16,
     435             :                         4.2724609375e-17,
     436             :                         2.288818359375e-18,
     437             :                         1.220703125e-19,
     438             :                         6.48498535156251e-21,
     439             :                         3.4332275390625e-22,
     440             :                         1.81198120117188e-23,
     441             :                         9.53674316406251e-25,
     442             :                         5.00679016113282e-26,
     443             :                         2.62260437011719e-27,
     444             :                         1.37090682983399e-28,
     445             :                         7.15255737304688e-30,
     446             :                         3.72529029846192e-31,
     447             :                         1.9371509552002e-32,
     448             :                         1.00582838058472e-33,
     449             :                         5.21540641784669e-35,
     450             :                         2.70083546638489e-36,
     451           2 :                         1.39698386192322e-37};
     452           1 :   double rc{0.0}, order{0.0};
     453             : 
     454           1 :   double err = threeterm(coeffs, scale, rc, order);
     455             : 
     456           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     457           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 2.0096e-13));
     458           1 :   EXPECT_THAT(order, DoubleNear(2.0, 2.49401e-12));
     459           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     460           1 : }
     461             : 
     462           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtZeroPoleAtOneWithScalingTenthAlphaTwo)
     463             : {
     464             :   // t = 0.0;
     465             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     466             : 
     467           1 :   double a{1.0};
     468           1 :   double time{0.0};
     469           1 :   double scale{0.1};
     470             :   vector<double> coeffs{1,       0.2,     0.03,
     471             :                         0.004,   0.0005,  6e-05,
     472             :                         7e-06,   8e-07,   9.00000000000001e-08,
     473             :                         1e-08,   1.1e-09, 1.2e-10,
     474             :                         1.3e-11, 1.4e-12, 1.5e-13,
     475             :                         1.6e-14, 1.7e-15, 1.8e-16,
     476             :                         1.9e-17, 2e-18,   2.1e-19,
     477             :                         2.2e-20, 2.3e-21, 2.4e-22,
     478             :                         2.5e-23, 2.6e-24, 2.7e-25,
     479           2 :                         2.8e-26, 2.9e-27, 3e-28};
     480           1 :   double rc{0.0}, order{0.0};
     481             : 
     482           1 :   double err = threeterm(coeffs, scale, rc, order);
     483             : 
     484           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     485           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 3.77476e-15));
     486           1 :   EXPECT_THAT(order, DoubleNear(2.0, 9.32588e-14));
     487           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     488           1 : }
     489             : 
     490           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtPT9PoleAtOneWithScalingTenthAlphaTwo)
     491             : {
     492             :   // t = 0.9;
     493             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     494             : 
     495           1 :   double a{1.0};
     496           1 :   double time{0.9};
     497           1 :   double scale{0.1};
     498             :   vector<double> coeffs{100,
     499             :                         200,
     500             :                         300,
     501             :                         400.000000000001,
     502             :                         500.000000000001,
     503             :                         600.000000000002,
     504             :                         700.000000000002,
     505             :                         800.000000000003,
     506             :                         900.000000000004,
     507             :                         1000,
     508             :                         1100.00000000001,
     509             :                         1200.00000000001,
     510             :                         1300.00000000001,
     511             :                         1400.00000000001,
     512             :                         1500.00000000001,
     513             :                         1600.00000000001,
     514             :                         1700.00000000001,
     515             :                         1800.00000000001,
     516             :                         1900.00000000002,
     517             :                         2000.00000000002,
     518             :                         2100.00000000002,
     519             :                         2200.00000000002,
     520             :                         2300.00000000003,
     521             :                         2400.00000000003,
     522             :                         2500.00000000003,
     523             :                         2600.00000000004,
     524             :                         2700.00000000004,
     525             :                         2800.00000000004,
     526             :                         2900.00000000005,
     527           2 :                         3000.00000000005};
     528           1 :   double rc{0.0}, order{0.0};
     529             : 
     530           1 :   double err = threeterm(coeffs, scale, rc, order);
     531             : 
     532           1 :   EXPECT_THAT(err, DoubleNear(0.0, 2.03727e-10));
     533           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 2.77556e-16));
     534           1 :   EXPECT_THAT(order, DoubleNear(2.0, 7.50511e-14));
     535           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     536           1 : }
     537             : 
     538           2 : TEST(ThreeTermAnalysisOf,
     539             :      TaylorSeriesAtNegativeOnePoleAtOneWithScalingOneAlphaTwo)
     540             : {
     541             :   // t =-1.0;
     542             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     543             : 
     544           1 :   double a{1.0};
     545           1 :   double time{-1.0};
     546           1 :   double scale{1.0};
     547             :   vector<double> coeffs{
     548             :       2.500000000000000e-01, 2.500000000000000e-01, 1.875000000000000e-01,
     549             :       1.250000000000000e-01, 7.812500000000000e-02, 4.687500000000000e-02,
     550             :       2.734375000000000e-02, 1.562500000000000e-02, 8.789062500000000e-03,
     551             :       4.882812500000000e-03, 2.685546875000000e-03, 1.464843750000000e-03,
     552             :       7.934570312500000e-04, 4.272460937500000e-04, 2.288818359375000e-04,
     553             :       1.220703125000000e-04, 6.484985351562500e-05, 3.433227539062500e-05,
     554             :       1.811981201171875e-05, 9.536743164062500e-06, 5.006790161132813e-06,
     555             :       2.622604370117188e-06, 1.370906829833984e-06, 7.152557373046875e-07,
     556             :       3.725290298461914e-07, 1.937150955200195e-07, 1.005828380584717e-07,
     557           2 :       5.215406417846680e-08, 2.700835466384888e-08, 1.396983861923218e-08};
     558           1 :   double rc{0.0}, order{0.0};
     559             : 
     560           1 :   double err = threeterm(coeffs, scale, rc, order);
     561             : 
     562           1 :   EXPECT_THAT(err, DoubleNear(0.0, epsilon));
     563           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 6.66134e-15));
     564           1 :   EXPECT_THAT(order, DoubleNear(2.0, 8.34888e-14));
     565           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     566           1 : }
     567             : 
     568           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtZeroPoleAtOneWithScalingOneAlphaTwo)
     569             : {
     570             :   // t = 0.0;
     571             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     572             : 
     573           1 :   double a{1.0};
     574           1 :   double time{0.0};
     575           1 :   double scale{1.0};
     576             :   vector<double> coeffs{1,  2,  3,  4,  5,  6,  7,  8,  9,  10,
     577             :                         11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
     578           2 :                         21, 22, 23, 24, 25, 26, 27, 28, 29, 30};
     579           1 :   double rc{0.0}, order{0.0};
     580             : 
     581           1 :   double err = threeterm(coeffs, scale, rc, order);
     582             : 
     583           1 :   EXPECT_THAT(err, DoubleNear(0.0, 3.97904e-13));
     584           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 1.11023e-15));
     585           1 :   EXPECT_THAT(order, DoubleNear(2.0, 4.17444e-14));
     586           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     587           1 : }
     588             : 
     589           2 : TEST(ThreeTermAnalysisOf, TaylorSeriesAtPT9PoleAtOneWithScalingOneAlphaTwo)
     590             : {
     591             :   // t = 0.9;
     592             :   // x[0] = 1.0/((1.0-t)*(1.0-t));
     593             : 
     594           1 :   double a{1.0};
     595           1 :   double time{0.9};
     596           1 :   double scale{1.0};
     597             :   vector<double> coeffs{
     598             :       1.000000000000001e+02, 2.000000000000002e+03, 3.000000000000004e+04,
     599             :       4.000000000000006e+05, 5.000000000000010e+06, 6.000000000000015e+07,
     600             :       7.000000000000021e+08, 8.000000000000028e+09, 9.000000000000035e+10,
     601             :       1.000000000000004e+12, 1.100000000000005e+13, 1.200000000000006e+14,
     602             :       1.300000000000008e+15, 1.400000000000009e+16, 1.500000000000010e+17,
     603             :       1.600000000000010e+18, 1.700000000000012e+19, 1.800000000000013e+20,
     604             :       1.900000000000014e+21, 2.000000000000016e+22, 2.100000000000018e+23,
     605             :       2.200000000000020e+24, 2.300000000000022e+25, 2.400000000000025e+26,
     606             :       2.500000000000028e+27, 2.600000000000031e+28, 2.700000000000035e+29,
     607           2 :       2.800000000000039e+30, 2.900000000000042e+31, 3.000000000000046e+32};
     608           1 :   double rc{0.0}, order{0.0};
     609             : 
     610           1 :   double err = threeterm(coeffs, scale, rc, order);
     611             : 
     612           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.71799e+12));
     613           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 1.27676e-15));
     614           1 :   EXPECT_THAT(order, DoubleNear(2.0, 3.61711e-13));
     615           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     616           1 : }
     617             : 
     618           2 : TEST(
     619             :     ThreeTermAnalysisOf,
     620             :     TaylorSeriesAtNegativePT3WithScalingTenthForComplexConjugatePolesAtPMOneFifthAlphaOne)
     621             : {
     622             :   // t =-0.3;
     623             :   // x[0] = 1.0/(1.0+25.0*t*t);
     624             : 
     625           1 :   double a{1.0 / 5.0};
     626           1 :   double time{-0.3};
     627           1 :   double scale{0.1};
     628             :   vector<double> coeffs{3.0769230769230771e-01,  1.4201183431952663e-01,
     629             :                         4.1875284478834776e-02,  8.4030671194986195e-03,
     630             :                         6.5716294139668780e-04,  -3.4308380547065328e-04,
     631             :                         -2.0889736724773902e-04, -7.0023107539675438e-05,
     632             :                         -1.6249329076177969e-05, -2.1132974551840289e-06,
     633             :                         2.7458033423644587e-07,  2.8929072773866954e-07,
     634             :                         1.1239723324581319e-07,  2.9622513210477662e-08,
     635             :                         5.0259881551579064e-09,  4.1031978497675339e-11,
     636             :                         -3.6767663724398882e-10, -1.7285321553550831e-10,
     637             :                         -5.1495588920697002e-11, -1.0470793691436441e-11,
     638             :                         -8.7147486368628090e-13, 4.0322650071682737e-13,
     639             :                         2.5314106676824962e-13,  8.5816915376359253e-14,
     640             :                         2.0135417345377379e-14,  2.6919683612234631e-15,
     641             :                         -3.0643132138743080e-16, -3.4850432996523446e-16,
     642           2 :                         -1.3727651218492121e-16, -3.6550364857253289e-17};
     643           1 :   double rc{0.0}, order{0.0};
     644             : 
     645           1 :   double err = threeterm(coeffs, scale, rc, order);
     646             : 
     647             :   // Model is wrong, as it should be. However there are no difficulties
     648             :   // executing this test case
     649           1 :   EXPECT_THAT(err, DoubleNear(0.0, 1.54316e-12));
     650           1 :   EXPECT_THAT(rc, DoubleNear(a - time, 0.545748));
     651           1 :   EXPECT_THAT(order, DoubleNear(1.0, 26.5676));
     652           1 :   EXPECT_THAT(coeffs.size(), Eq(30));
     653           1 : }
     654             : 
     655           2 : TEST(ThreeTermAnalysisOf, TestRCThree)
     656             : {
     657           1 :   double rc = std::numeric_limits<double>::quiet_NaN();
     658           2 :   EXPECT_THROW(testRCThree(rc), std::exception);
     659           1 : }
     660             : 
     661           2 : TEST(ThreeTermAnalysisOf, TestOrder)
     662             : {
     663           1 :   double order = std::numeric_limits<double>::quiet_NaN();
     664           2 :   EXPECT_THROW(testOrder(order), std::exception);
     665           1 : }
     666             : 
     667             : // WARNING Rc and order can be accurate, but backward error can be large near
     668             : // singularity WARNING Error model wrong for complex-conjugate comparison
     669             : //
     670             : // Exceptions (Hard to think of a test)
     671             : // Top-line comparison

Generated by: LCOV version 1.14