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 "sixterm.hpp"
8 :
9 : #define epsilon DBL_EPSILON
10 : using namespace testing;
11 : using namespace std;
12 :
13 2 : TEST(
14 : SixTermAnalysisOf,
15 : TaylorSeriesAtNegativePT3WithScalingTenthForComplexConjugatePolesAtPMOneFifthAlphaOne)
16 : {
17 : // t =-0.3;
18 : // x[0] = 1.0/(1.0+25.0*t*t);
19 :
20 1 : double a{1.0 / 5.0};
21 1 : double time{-0.3};
22 1 : double scale{0.1};
23 : vector<double> coeffs{3.0769230769230771e-01, 1.4201183431952663e-01,
24 : 4.1875284478834776e-02, 8.4030671194986195e-03,
25 : 6.5716294139668780e-04, -3.4308380547065328e-04,
26 : -2.0889736724773902e-04, -7.0023107539675438e-05,
27 : -1.6249329076177969e-05, -2.1132974551840289e-06,
28 : 2.7458033423644587e-07, 2.8929072773866954e-07,
29 : 1.1239723324581319e-07, 2.9622513210477662e-08,
30 : 5.0259881551579064e-09, 4.1031978497675339e-11,
31 : -3.6767663724398882e-10, -1.7285321553550831e-10,
32 : -5.1495588920697002e-11, -1.0470793691436441e-11,
33 : -8.7147486368628090e-13, 4.0322650071682737e-13,
34 : 2.5314106676824962e-13, 8.5816915376359253e-14,
35 : 2.0135417345377379e-14, 2.6919683612234631e-15,
36 : -3.0643132138743080e-16, -3.4850432996523446e-16,
37 2 : -1.3727651218492121e-16, -3.6550364857253289e-17};
38 1 : double rc{0.0}, order{0.0};
39 :
40 1 : double err = sixterm(coeffs, scale, rc, order);
41 :
42 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
43 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), 2.44250e-15));
44 1 : EXPECT_THAT(order, DoubleNear(1.0, 2.6712e-13));
45 1 : EXPECT_THAT(coeffs.size(), Eq(30));
46 1 : }
47 :
48 2 : TEST(
49 : SixTermAnalysisOf,
50 : TaylorSeriesAtZeroWithScalingTenthForComplexConjugatePolesAtPMOneFifthAlphaOne)
51 : {
52 : // t = 0.0;
53 : // x[0] = 1.0/(1.0+25.0*t*t);
54 :
55 1 : double a{1.0 / 5.0};
56 1 : double time{0.0};
57 1 : double scale{0.1};
58 : vector<double> coeffs{
59 : 1.0000000000000000e+00, 0.0000000000000000e+00, -2.5000000000000000e-01,
60 : 0.0000000000000000e+00, 6.2500000000000000e-02, 0.0000000000000000e+00,
61 : -1.5625000000000000e-02, 0.0000000000000000e+00, 3.9062500000000000e-03,
62 : 0.0000000000000000e+00, -9.7656250000000000e-04, 0.0000000000000000e+00,
63 : 2.4414062500000000e-04, 0.0000000000000000e+00, -6.1035156250000000e-05,
64 : 0.0000000000000000e+00, 1.5258789062500000e-05, 0.0000000000000000e+00,
65 : -3.8146972656250000e-06, 0.0000000000000000e+00, 9.5367431640625000e-07,
66 : 0.0000000000000000e+00, -2.3841857910156250e-07, 0.0000000000000000e+00,
67 : 5.9604644775390625e-08, 0.0000000000000000e+00, -1.4901161193847656e-08,
68 2 : 0.0000000000000000e+00, 3.7252902984619141e-09, 0.0000000000000000e+00};
69 1 : double rc{0.0}, order{0.0};
70 :
71 1 : double err = sixterm(coeffs, scale, rc, order);
72 :
73 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
74 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), epsilon));
75 1 : EXPECT_THAT(order, DoubleNear(1.0, 1.78746e-14));
76 1 : EXPECT_THAT(coeffs.size(), Eq(30));
77 1 : }
78 :
79 2 : TEST(
80 : SixTermAnalysisOf,
81 : TaylorSeriesAtPT3WithScalingTenthForComplexConjugatePolesAtPMOneFifthAlphaOne)
82 : {
83 : // t = 0.3;
84 : // x[0] = 1.0/(1.0+25.0*t*t);
85 :
86 1 : double a{1.0 / 5.0};
87 1 : double time{0.3};
88 1 : double scale{0.1};
89 : vector<double> coeffs{
90 : 3.0769230769230771e-01, -1.4201183431952663e-01, 4.1875284478834776e-02,
91 : -8.4030671194986195e-03, 6.5716294139668780e-04, 3.4308380547065328e-04,
92 : -2.0889736724773902e-04, 7.0023107539675438e-05, -1.6249329076177969e-05,
93 : 2.1132974551840289e-06, 2.7458033423644587e-07, -2.8929072773866954e-07,
94 : 1.1239723324581319e-07, -2.9622513210477662e-08, 5.0259881551579064e-09,
95 : -4.1031978497675339e-11, -3.6767663724398882e-10, 1.7285321553550831e-10,
96 : -5.1495588920697002e-11, 1.0470793691436441e-11, -8.7147486368628090e-13,
97 : -4.0322650071682737e-13, 2.5314106676824962e-13, -8.5816915376359253e-14,
98 : 2.0135417345377379e-14, -2.6919683612234631e-15, -3.0643132138743080e-16,
99 2 : 3.4850432996523446e-16, -1.3727651218492121e-16, 3.6550364857253289e-17};
100 1 : double rc{0.0}, order{0.0};
101 :
102 1 : double err = sixterm(coeffs, scale, rc, order);
103 :
104 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
105 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), 2.44250e-15));
106 1 : EXPECT_THAT(order, DoubleNear(1.0, 2.6712e-13));
107 1 : EXPECT_THAT(coeffs.size(), Eq(30));
108 1 : }
109 :
110 2 : TEST(
111 : SixTermAnalysisOf,
112 : TaylorSeriesAtNegativePT3WithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaOne)
113 : {
114 : // t =-0.3;
115 : // x[0] = 1.0/(1.0+25.0*t*t);
116 :
117 : // double a{1.0/5.0};
118 : // double time{-0.3};
119 1 : double scale{1.0};
120 : vector<double> coeffs{3.0769230769230771e-01, 1.4201183431952664e+00,
121 : 4.1875284478834782e+00, 8.4030671194986173e+00,
122 : 6.5716294139668623e+00, -3.4308380547065390e+01,
123 : -2.0889736724773917e+02, -7.0023107539675470e+02,
124 : -1.6249329076177976e+03, -2.1132974551840298e+03,
125 : 2.7458033423644597e+03, 2.8929072773866963e+04,
126 : 1.1239723324581322e+05, 2.9622513210477668e+05,
127 : 5.0259881551579072e+05, 4.1031978497674834e+04,
128 : -3.6767663724398911e+06, -1.7285321553550843e+07,
129 : -5.1495588920697041e+07, -1.0470793691436444e+08,
130 : -8.7147486368627921e+07, 4.0322650071682835e+08,
131 : 2.5314106676824994e+09, 8.5816915376359320e+09,
132 : 2.0135417345377384e+10, 2.6919683612234612e+10,
133 : -3.0643132138743221e+10, -3.4850432996523499e+11,
134 1 : -1.3727651218492134e+12, -3.6550364857253306e+12};
135 1 : double rc{0.0}, order{0.0};
136 :
137 : // Cos(Theta) = 5.063697
138 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
139 : }
140 :
141 2 : TEST(
142 : SixTermAnalysisOf,
143 : TaylorSeriesAtZeroWithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaOne)
144 : {
145 : // t = 0.0;
146 : // x[0] = 1.0/(1.0+25.0*t*t);
147 :
148 : // double a{1.0/5.0};
149 : // double time{0.0};
150 1 : double scale{1.0};
151 : vector<double> coeffs{
152 : 1.0000000000000000e+00, 0.0000000000000000e+00, -2.5000000000000000e+01,
153 : 0.0000000000000000e+00, 6.2500000000000000e+02, 0.0000000000000000e+00,
154 : -1.5625000000000000e+04, 0.0000000000000000e+00, 3.9062500000000000e+05,
155 : 0.0000000000000000e+00, -9.7656250000000000e+06, 0.0000000000000000e+00,
156 : 2.4414062500000000e+08, 0.0000000000000000e+00, -6.1035156250000000e+09,
157 : 0.0000000000000000e+00, 1.5258789062500000e+11, 0.0000000000000000e+00,
158 : -3.8146972656250000e+12, 0.0000000000000000e+00, 9.5367431640625000e+13,
159 : 0.0000000000000000e+00, -2.3841857910156250e+15, 0.0000000000000000e+00,
160 : 5.9604644775390624e+16, 0.0000000000000000e+00, -1.4901161193847657e+18,
161 1 : 0.0000000000000000e+00, 3.7252902984619139e+19, 0.0000000000000000e+00};
162 1 : double rc{0.0}, order{0.0};
163 :
164 : // Cos(Theta) = 13934294.457978
165 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
166 : }
167 :
168 2 : TEST(
169 : SixTermAnalysisOf,
170 : TaylorSeriesAtPT3WithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaOne)
171 : {
172 : // t = 0.3;
173 : // x[0] = 1.0/(1.0+25.0*t*t);
174 :
175 : // double a{1.0/5.0};
176 : // double time{0.3};
177 1 : double scale{1.0};
178 : vector<double> coeffs{
179 : 3.0769230769230771e-01, -1.4201183431952664e+00, 4.1875284478834782e+00,
180 : -8.4030671194986173e+00, 6.5716294139668623e+00, 3.4308380547065390e+01,
181 : -2.0889736724773917e+02, 7.0023107539675470e+02, -1.6249329076177976e+03,
182 : 2.1132974551840298e+03, 2.7458033423644597e+03, -2.8929072773866963e+04,
183 : 1.1239723324581322e+05, -2.9622513210477668e+05, 5.0259881551579072e+05,
184 : -4.1031978497674834e+04, -3.6767663724398911e+06, 1.7285321553550843e+07,
185 : -5.1495588920697041e+07, 1.0470793691436444e+08, -8.7147486368627921e+07,
186 : -4.0322650071682835e+08, 2.5314106676824994e+09, -8.5816915376359320e+09,
187 : 2.0135417345377384e+10, -2.6919683612234612e+10, -3.0643132138743221e+10,
188 1 : 3.4850432996523499e+11, -1.3727651218492134e+12, 3.6550364857253306e+12};
189 1 : double rc{0.0}, order{0.0};
190 :
191 : // Unconstrained optimization lead to Sqrt of negative number: -2.307692
192 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
193 : }
194 :
195 2 : TEST(
196 : SixTermAnalysisOf,
197 : TaylorSeriesAtNegativePT3WithScalingHundredthForComplexConjugatePolesAtPMOneFifthAlphaThree)
198 : {
199 : // t =-0.3;
200 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.14159};
201 :
202 1 : double a{1.0 / 5.0};
203 1 : double time{-0.3};
204 1 : double scale{0.01};
205 : vector<double> coeffs{
206 : 2.4655761562767709e-02, 3.5748957668969889e-03, 2.8208219200667809e-04,
207 : 1.5636812703033154e-05, 6.5875429164410868e-07, 2.1094322169896426e-08,
208 : 4.5261475074311576e-10, 1.1260909441922327e-12, -4.6867806776404976e-13,
209 : -2.8056792096691283e-14, -1.0573048948187840e-15, -2.8313453349783412e-17,
210 : -4.3638374553989396e-19, 5.4965174709350763e-21, 7.3086407830397857e-22,
211 : 3.3112669205272192e-23, 1.0201294809137287e-24, 2.1125410354692833e-26,
212 : 1.1958555283498346e-28, -1.3772058760031110e-29, -8.1538224313874953e-31,
213 : -2.8716158576770647e-32, -7.0504814826739304e-34, -9.3677299909588449e-36,
214 : 1.6819506294660599e-37, 1.6868283550256514e-38, 6.9196677516458404e-40,
215 2 : 1.9436081834894383e-41, 3.5195594052044087e-43, 2.8474916689612392e-46};
216 1 : double rc{0.0}, order{0.0};
217 :
218 1 : double err = sixterm(coeffs, scale, rc, order);
219 :
220 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
221 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), 3.75922e-13));
222 1 : EXPECT_THAT(order, DoubleNear(3.14159, 9.0000100000000000e-5));
223 1 : EXPECT_THAT(coeffs.size(), Eq(30));
224 1 : }
225 :
226 2 : TEST(
227 : SixTermAnalysisOf,
228 : TaylorSeriesAtZeroWithScalingThousandthForComplexConjugatePolesAtPMOneFifthAlphaThree)
229 : {
230 : // t = 0.0;
231 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.14159};
232 :
233 1 : double a{1.0 / 5.0};
234 1 : double time{0.0};
235 1 : double scale{0.001};
236 : vector<double> coeffs{
237 : 1.0000000000000000e+00, 0.0000000000000000e+00, -7.8537500000000005e-05,
238 : 0.0000000000000000e+00, 4.0657882031250008e-09, 0.0000000000000000e+00,
239 : -1.7420208371972664e-13, 0.0000000000000000e+00, 6.6866381072793826e-18,
240 : 0.0000000000000000e+00, -2.3876313021567852e-22, 0.0000000000000000e+00,
241 : 8.0995417693789439e-27, 0.0000000000000000e+00, -2.6443557530277716e-31,
242 : 0.0000000000000000e+00, 8.3805418341659806e-36, 0.0000000000000000e+00,
243 : -2.5936613012600057e-40, 0.0000000000000000e+00, 7.8727346723120797e-45,
244 : 0.0000000000000000e+00, -2.3513532430952043e-49, 0.0000000000000000e+00,
245 : 6.9274295598397387e-54, 0.0000000000000000e+00, -2.0171475900060203e-58,
246 2 : 0.0000000000000000e+00, 5.8142478257289360e-63, 0.0000000000000000e+00};
247 1 : double rc{0.0}, order{0.0};
248 :
249 1 : double err = sixterm(coeffs, scale, rc, order);
250 :
251 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
252 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), 1.55432e-15));
253 1 : EXPECT_THAT(order, DoubleNear(3.14159, 0.000089999999827));
254 1 : EXPECT_THAT(coeffs.size(), Eq(30));
255 1 : }
256 :
257 2 : TEST(
258 : SixTermAnalysisOf,
259 : TaylorSeriesAtPT3WithScalingThousandthForComplexConjugatePolesAtPMOneFifthAlphaThree)
260 : {
261 : // t = 0.3;
262 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.1415};
263 :
264 1 : double a{1.0 / 5.0};
265 1 : double time{0.3};
266 1 : double scale{0.001};
267 : vector<double> coeffs{2.4655761562767709e-02, -3.5748957668969888e-04,
268 : 2.8208219200667818e-06, -1.5636812703033177e-08,
269 : 6.5875429164411143e-11, -2.1094322169896626e-13,
270 : 4.5261475074312502e-16, -1.1260909441924017e-19,
271 : -4.6867806776406748e-21, 2.8056792096693676e-23,
272 : -1.0573048948189600e-25, 2.8313453349792976e-28,
273 : -4.3638374554030017e-31, -5.4965174709220135e-34,
274 : 7.3086407830372582e-36, -3.3112669205275378e-38,
275 : 1.0201294809143237e-40, -2.1125410354727341e-43,
276 : 1.1958555283637769e-46, 1.3772058759989342e-48,
277 : -8.1538224313796743e-51, 2.8716158576775504e-53,
278 : -7.0504814826864239e-56, 9.3677299910270096e-59,
279 : 1.6819506294408271e-61, -1.6868283550188946e-63,
280 : 6.9196677516356937e-66, -1.9436081834912157e-68,
281 2 : 3.5195594052256001e-71, -2.8474916699531912e-75};
282 1 : double rc{0.0}, order{0.0};
283 :
284 1 : double err = sixterm(coeffs, scale, rc, order);
285 :
286 1 : EXPECT_THAT(err, DoubleNear(0.0, epsilon));
287 1 : EXPECT_THAT(rc, DoubleNear(sqrt(a * a + time * time), 1.55432e-14));
288 1 : EXPECT_THAT(order, DoubleNear(3.14159, 0.000090000003478));
289 1 : EXPECT_THAT(coeffs.size(), Eq(30));
290 1 : }
291 :
292 2 : TEST(
293 : SixTermAnalysisOf,
294 : TaylorSeriesAtNegativePT3WithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaThree)
295 : {
296 : // t = 0.3;
297 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.1415};
298 :
299 : // double a{1.0/5.0};
300 : // double time{-0.3};
301 1 : double scale{1.0};
302 : vector<double> coeffs{
303 : 2.4655761562767709e-02, 3.5748957668969888e-01, 2.8208219200667819e+00,
304 : 1.5636812703033181e+01, 6.5875429164411216e+01, 2.1094322169896708e+02,
305 : 4.5261475074313199e+02, 1.1260909441928604e+02, -4.6867806776404268e+03,
306 : -2.8056792096692519e+04, -1.0573048948189148e+05, -2.8313453349791735e+05,
307 : -4.3638374554030015e+05, 5.4965174709191988e+05, 7.3086407830349784e+06,
308 : 3.3112669205263112e+07, 1.0201294809138143e+08, 2.1125410354710954e+08,
309 : 1.1958555283602265e+08, -1.3772058759989672e+09, -8.1538224313751421e+09,
310 : -2.8716158576746910e+10, -7.0504814826746704e+10, -9.3677299909914948e+10,
311 : 1.6819506294477527e+11, 1.6868283550187634e+12, 6.9196677516269053e+12,
312 1 : 1.9436081834863168e+13, 3.5195594052075742e+13, 2.8474916694776353e+12};
313 1 : double rc{0.0}, order{0.0};
314 :
315 : // Cos(Theta) = 8.975037
316 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
317 : }
318 :
319 2 : TEST(
320 : SixTermAnalysisOf,
321 : TaylorSeriesAtZeroWithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaThree)
322 : {
323 : // t = 0.3;
324 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.1415};
325 :
326 : // double a{1.0/5.0};
327 : // double time{0.0};
328 1 : double scale{1.0};
329 : vector<double> coeffs{
330 : 1.0000000000000000e+00, 0.0000000000000000e+00, -7.8537500000000009e+01,
331 : 0.0000000000000000e+00, 4.0657882031250006e+03, 0.0000000000000000e+00,
332 : -1.7420208371972659e+05, 0.0000000000000000e+00, 6.6866381072793789e+06,
333 : 0.0000000000000000e+00, -2.3876313021567836e+08, 0.0000000000000000e+00,
334 : 8.0995417693789396e+09, 0.0000000000000000e+00, -2.6443557530277716e+11,
335 : 0.0000000000000000e+00, 8.3805418341659883e+12, 0.0000000000000000e+00,
336 : -2.5936613012600116e+14, 0.0000000000000000e+00, 7.8727346723121130e+15,
337 : 0.0000000000000000e+00, -2.3513532430952214e+17, 0.0000000000000000e+00,
338 : 6.9274295598398177e+18, 0.0000000000000000e+00, -2.0171475900060536e+20,
339 1 : 0.0000000000000000e+00, 5.8142478257290687e+21, 0.0000000000000000e+00};
340 1 : double rc{0.0}, order{0.0};
341 :
342 : // Unconstrained optimization lead to Sqrt of negative number: -0.00000
343 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
344 : }
345 :
346 2 : TEST(
347 : SixTermAnalysisOf,
348 : TaylorSeriesAtPT3WithoutScalingForComplexConjugatePolesAtPMOneFifthAlphaThree)
349 : {
350 : // t = 0.3;
351 : // x[0] = 1.0/(1.0+25.0*t*t)^{3.1415};
352 :
353 : // double a{1.0/5.0};
354 : // double time{0.3};
355 1 : double scale{1.0};
356 : vector<double> coeffs{2.4655761562767709e-02, -3.5748957668969888e-01,
357 : 2.8208219200667819e+00, -1.5636812703033181e+01,
358 : 6.5875429164411216e+01, -2.1094322169896708e+02,
359 : 4.5261475074313199e+02, -1.1260909441928604e+02,
360 : -4.6867806776404268e+03, 2.8056792096692519e+04,
361 : -1.0573048948189148e+05, 2.8313453349791735e+05,
362 : -4.3638374554030015e+05, -5.4965174709191988e+05,
363 : 7.3086407830349784e+06, -3.3112669205263112e+07,
364 : 1.0201294809138143e+08, -2.1125410354710954e+08,
365 : 1.1958555283602265e+08, 1.3772058759989672e+09,
366 : -8.1538224313751421e+09, 2.8716158576746910e+10,
367 : -7.0504814826746704e+10, 9.3677299909914948e+10,
368 : 1.6819506294477527e+11, -1.6868283550187634e+12,
369 : 6.9196677516269053e+12, -1.9436081834863168e+13,
370 1 : 3.5195594052075742e+13, -2.8474916694776353e+12};
371 1 : double rc{0.0}, order{0.0};
372 :
373 : // Unconstrained optimization lead to Sqrt of negative number: -7.249615
374 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
375 : }
376 :
377 : // Test exception throws (Seems hard)
378 : // QRFactorization and QRSolve tested in the developement of these methods
379 : // SQRT tested above (by accident)
380 : // The radius of convergence is infinity, which is highly unlikely (NOT TESTED)
381 : // Unconstrained optimization lead to infinite CosTheta which is not in [-1, 1]
382 : // (NOT TESTED) Unconstrained optimization lead to CosTheta [" +
383 : // to_string(cosTheta) + "] not in [-1, 1] (by accident) Unconstrained
384 : // optimization lead to NaN for Order of Singularity (NOT TESTED)
385 : //
386 : // Test real pole, which should fail.
387 2 : TEST(
388 : SixTermAnalysisOf,
389 : TaylorSeriesAtNegativeOneNearARealPoleAtOneWithScalingTenthAlphaOneExpectedToFail)
390 : {
391 : // t =-1.0;
392 : // x[0] = 1.0/(1.0-t);
393 :
394 : // double a{1.0};
395 : // double time{-1.0};
396 1 : double scale{0.1};
397 : vector<double> coeffs{0.5,
398 : 0.025,
399 : 0.00125,
400 : 6.25e-05,
401 : 3.125e-06,
402 : 1.5625e-07,
403 : 7.8125e-09,
404 : 3.90625e-10,
405 : 1.953125e-11,
406 : 9.765625e-13,
407 : 4.8828125e-14,
408 : 2.44140625e-15,
409 : 1.220703125e-16,
410 : 6.103515625e-18,
411 : 3.0517578125e-19,
412 : 1.52587890625e-20,
413 : 7.62939453125001e-22,
414 : 3.814697265625e-23,
415 : 1.9073486328125e-24,
416 : 9.53674316406251e-26,
417 : 4.76837158203126e-27,
418 : 2.38418579101563e-28,
419 : 1.19209289550781e-29,
420 : 5.96046447753907e-31,
421 : 2.98023223876954e-32,
422 : 1.49011611938477e-33,
423 : 7.45058059692384e-35,
424 : 3.72529029846192e-36,
425 : 1.86264514923096e-37,
426 1 : 9.3132257461548e-39};
427 1 : double rc{0.0}, order{0.0};
428 :
429 : // Unconstrained optimization lead to Sqrt of negative number: -0.360944
430 2 : ASSERT_THROW(sixterm(coeffs, scale, rc, order), std::exception);
431 : }
432 :
433 2 : TEST(SixTermAnalysisOf, TestBeta4)
434 : {
435 1 : double beta4 = -1.0;
436 2 : EXPECT_THROW(testBeta4(beta4), std::exception);
437 1 : }
438 :
439 2 : TEST(SixTermAnalysisOf, TestRCSix)
440 : {
441 1 : double rc = std::numeric_limits<double>::quiet_NaN();
442 2 : EXPECT_THROW(testRCSix(rc), std::exception);
443 1 : }
444 :
445 2 : TEST(SixTermAnalysisOf, TestCosThetaNAN)
446 : {
447 1 : double cosTheta = std::numeric_limits<double>::quiet_NaN();
448 2 : EXPECT_THROW(testCosTheta(cosTheta), std::exception);
449 1 : }
450 :
451 2 : TEST(SixTermAnalysisOf, TestCosThetaLessThanNegativeOne)
452 : {
453 1 : double cosTheta = -2.0;
454 2 : EXPECT_THROW(testCosTheta(cosTheta), std::exception);
455 1 : }
456 :
457 2 : TEST(SixTermAnalysisOf, TestCosThetaGreaterThanPositiveOne)
458 : {
459 1 : double cosTheta = 2.0;
460 2 : EXPECT_THROW(testCosTheta(cosTheta), std::exception);
461 1 : }
462 :
463 2 : TEST(SixTermAnalysisOf, TestSingularityOrderBothNAN)
464 : {
465 1 : double singularityOrder1 = std::numeric_limits<double>::quiet_NaN();
466 1 : double singularityOrder2 = std::numeric_limits<double>::quiet_NaN();
467 :
468 2 : EXPECT_THROW(testSingularityOrder(singularityOrder1, singularityOrder2),
469 : std::exception);
470 1 : }
471 :
472 2 : TEST(SixTermAnalysisOf,
473 : TestSingularityOrderSingularityOrderOneIsNANSingularityOrderTwoIsOne)
474 : {
475 1 : double singularityOrder1 = std::numeric_limits<double>::quiet_NaN();
476 1 : double singularityOrder2 = 1.0;
477 :
478 1 : EXPECT_THAT(testSingularityOrder(singularityOrder1, singularityOrder2),
479 : DoubleNear(1.0, epsilon));
480 1 : }
481 :
482 2 : TEST(SixTermAnalysisOf,
483 : TestSingularityOrderSingularityOrderOneIsOneSingularityOrderTwoIsNAN)
484 : {
485 1 : double singularityOrder1 = 1.0;
486 1 : double singularityOrder2 = std::numeric_limits<double>::quiet_NaN();
487 :
488 1 : EXPECT_THAT(testSingularityOrder(singularityOrder1, singularityOrder2),
489 : DoubleNear(1.0, epsilon));
490 1 : }
491 :
492 2 : TEST(
493 : SixTermAnalysisOf,
494 : TestSingularityOrderSingularityOrderOneIsOneSingularityOrderTwoIsThreeOrderIsAverage)
495 : {
496 1 : double singularityOrder1 = 1.0;
497 1 : double singularityOrder2 = 3.0;
498 :
499 1 : EXPECT_THAT(testSingularityOrder(singularityOrder1, singularityOrder2),
500 : DoubleNear(2.0, epsilon));
501 1 : }
|