Quartic roots
Utilities for C++ programming
Loading...
Searching...
No Matches
PolynomialRoots.hh
Go to the documentation of this file.
1/*--------------------------------------------------------------------------*\
2 | |
3 | Copyright (C) 2014 |
4 | |
5 | , __ , __ |
6 | /|/ \ /|/ \ |
7 | | __/ _ ,_ | __/ _ ,_ |
8 | | \|/ / | | | | \|/ / | | | |
9 | |(__/|__/ |_/ \_/|/|(__/|__/ |_/ \_/|/ |
10 | /| /| |
11 | \| \| |
12 | |
13 | Enrico Bertolazzi |
14 | Dipartimento di Ingegneria Industriale |
15 | Universita` degli Studi di Trento |
16 | email: enrico.bertolazzi@unitn.it |
17 | |
18\*--------------------------------------------------------------------------*/
19
20#ifndef POLYNOMIAL_ROOTS_HH
21#define POLYNOMIAL_ROOTS_HH
22
23#include <cmath>
24#include <cfloat>
25#include <complex>
26#include <iostream>
27
48namespace PolynomialRoots {
49
50 using real_type = double;
51 using integer = int;
52 using complex_type = std::complex<real_type>;
53 using ostream_type = std::basic_ostream<char>;
54 using istream_type = std::basic_istream<char>;
55
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
57
59 static
60 inline
61 bool
62 isZero( real_type x )
63 { return FP_ZERO == std::fpclassify(x); }
64
67 evalPoly(
68 real_type const op[],
69 integer Degree,
70 real_type x
71 );
72
73 void
74 evalPolyDPoly(
75 real_type const op[],
76 integer Degree,
77 real_type x,
78 real_type & p,
79 real_type & dp
80 );
81
82 bool
83 NewtonStep(
84 real_type const op[],
85 integer Degree,
86 real_type & x
87 );
88
91 evalPolyC(
92 real_type const op[],
93 integer Degree,
95 );
96
97 #endif
98
109 int
110 roots(
111 real_type const * op,
112 integer Degree,
113 real_type * zeror,
114 real_type * zeroi
115 );
116
117 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
118 /*\
119 | ___ _ _ _
120 | / _ \ _ _ __ _ __| |_ __ __ _| |_(_) ___
121 | | | | | | | |/ _` |/ _` | '__/ _` | __| |/ __|
122 | | |_| | |_| | (_| | (_| | | | (_| | |_| | (__
123 | \__\_\\__,_|\__,_|\__,_|_| \__,_|\__|_|\___|
124 |
125 | A * x^2 + B * x + C
126 \*/
195 class Quadratic {
196 real_type m_ABC[3]{0,0,0};
197 real_type m_r0{0}, m_r1{0};
198 integer m_nrts{0};
199 bool m_cplx{false};
200 bool m_dblx{false};
201
202 void find_roots();
203
204 public:
205
207
219 using std::isfinite;
220 real_type & A{ m_ABC[0] };
221 real_type & B{ m_ABC[1] };
222 real_type & C{ m_ABC[2] };
223 A = a; B = b; C = c;
224 // find roots only on finite values
225 if ( isfinite(a) && isfinite(b) && isfinite(c) ) {
226 find_roots();
227 }
228 }
229
239 void
241 real_type & A = m_ABC[0];
242 real_type & B = m_ABC[1];
243 real_type & C = m_ABC[2];
244 A = a; B = b; C = c;
245 find_roots();
246 }
247
258 integer num_roots() const { return m_nrts; }
259
261 integer numRoots() const { return m_nrts; }
262
266 bool complex_root() const { return m_cplx; }
267
269 bool complexRoot() const { return m_cplx; }
270
274 bool double_root() const { return m_dblx; }
275
277 bool doubleRoot() const { return m_dblx; }
278
286
288 integer getRealRoots( real_type r[] ) const { return get_real_roots(r); }
289
297
300
308
311
321
323 integer
325 { return get_roots_in_range( a, b, r ); }
326
336
338 integer
340 { return get_roots_in_open_range( a, b, r ); }
341
345 real_type real_root0() const { return m_r0; }
346
350 real_type real_root1() const { return m_r1; }
351
355 complex_type root0() const { return m_cplx ? complex_type(m_r0,m_r1) : complex_type(m_r0,0); }
356
360 complex_type root1() const { return m_cplx ? complex_type(m_r0,-m_r1) : complex_type(m_r1,0); }
361
368 void
369 get_root0( real_type & re, real_type & im ) const {
370 if ( m_cplx ) { re = m_r0; im = m_r1; }
371 else { re = m_r0; im = 0; }
372 }
373
375 void
376 getRoot0( real_type & re, real_type & im ) const
377 { return get_root0( re, im ); }
378
384 void
386 { r = m_cplx ? complex_type(m_r0,m_r1) : complex_type(m_r0,0); }
387
389 void getRoot0( complex_type & r ) const { return get_root0( r ); }
390
397 void
398 get_root1( real_type & re, real_type & im ) const {
399 if ( m_cplx ) { re = m_r0; im = -m_r1; }
400 else { re = m_r1; im = 0; }
401 }
402
404 void
405 getRoot1( real_type & re, real_type & im ) const
406 { return get_root1( re, im ); }
407
413 void
415 { r = m_cplx ? complex_type(m_r0,-m_r1) : complex_type(m_r1,0); }
416
418 void getRoot1( complex_type & r ) const { return get_root1( r ); }
419
427 eval( real_type x ) const
428 { return evalPoly( m_ABC, 2, x ); }
429
438 { return evalPolyC( m_ABC, 2, x ); }
439
447 void
448 eval( real_type x, real_type & p, real_type & dp ) const {
449 evalPolyDPoly( m_ABC, 2, x, p, dp );
450 }
451
455 void
456 info( ostream_type & s ) const;
457
461 bool
462 check( ostream_type & s ) const;
463 };
464
465 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
466 /*\
467 | ____ _ _
468 | / ___| _| |__ (_) ___
469 | | | | | | | '_ \| |/ __|
470 | | |__| |_| | |_) | | (__
471 | \____\__,_|_.__/|_|\___|
472 |
473 | A * x^3 + B * x^2 + C * x + D
474 \*/
549 class Cubic {
550 real_type m_ABCD[4]{0,0,0,0};
551 real_type m_r0{0}, m_r1{0}, m_r2{0};
552 integer m_nrts{0};
553 integer m_iter{0};
554 bool m_cplx{false}; // complex root
555 bool m_dblx{false}; // double root
556 bool m_trpx{false}; // triple root
557
558 void find_roots();
559
560 public:
561
565 Cubic() {}
566
577 using std::isfinite;
578 real_type & A = m_ABCD[0];
579 real_type & B = m_ABCD[1];
580 real_type & C = m_ABCD[2];
581 real_type & D = m_ABCD[3];
582 A = a; B = b; C = c; D = d;
583 // find roots only on finite values
584 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) ) {
585 find_roots();
586 }
587 }
588
598 void
600 using std::isfinite;
601 real_type & A{m_ABCD[0]};
602 real_type & B{m_ABCD[1]};
603 real_type & C{m_ABCD[2]};
604 real_type & D{m_ABCD[3]};
605 m_nrts = 0;
606 m_iter = 0;
607 m_cplx = false; // complex root
608 m_dblx = false; // double root
609 m_trpx = false; // triple root
610 A = a; B = b; C = c; D = d;
611 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) ) {
612 find_roots();
613 }
614 }
615
619 integer num_roots() const { return m_nrts; }
620
622 integer numRoots() const { return m_nrts; }
623
627 bool complex_root() const { return m_cplx; }
628
630 bool complexRoot() const { return m_cplx; }
631
635 bool double_root() const { return m_dblx; }
636
638 bool doubleRoot() const { return m_dblx; }
639
643 bool triple_root() const { return m_trpx; }
644
646 bool tripleRoot() const { return m_trpx; }
647
655
657 integer
659 { return get_real_roots( r ); }
660
668
670 integer
672 { return get_positive_roots( r ); }
673
681
683 integer
685 { return get_negative_roots( r ); }
686
696
698 integer
700 { return get_roots_in_range( a, b, r ); }
701
711
713 integer
715 { return get_roots_in_open_range( a, b, r ); }
716
720 real_type real_root0() const { return m_r0; }
721
725 real_type real_root1() const { return m_r1; }
726
730 real_type real_root2() const { return m_r2; }
731
736 root0() const
737 { return m_cplx ? complex_type(m_r0,m_r1) : complex_type(m_r0,0); }
738
743 root1() const
744 { return m_cplx ? complex_type(m_r0,-m_r1) : complex_type(m_r1,0); }
745
750 root2() const
751 { return complex_type(m_r2,0); }
752
756 void
757 get_root0( real_type & re, real_type & im ) const {
758 if ( m_cplx ) { re = m_r0; im = m_r1; }
759 else { re = m_r0; im = 0; }
760 }
761
763 void getRoot0( real_type & re, real_type & im ) const { get_root0( re, im ); }
764
768 void
770 { r = m_cplx ? complex_type(m_r0,m_r1) : complex_type(m_r0,0); }
771
773 void getRoot0( complex_type & r ) const { get_root0( r ); }
774
778 void
779 get_root1( real_type & re, real_type & im ) const {
780 if ( m_cplx ) { re = m_r0; im = -m_r1; }
781 else { re = m_r1; im = 0; }
782 }
783
785 void getRoot1( real_type & re, real_type & im ) const { get_root1( re, im ); }
786
790 void
792 { r = m_cplx ? complex_type(m_r0,-m_r1) : complex_type(m_r1,0); }
793
795 void getRoot1( complex_type & r ) const { get_root1( r ); }
796
800 void
801 get_root2( real_type & re, real_type & im ) const
802 { re = m_r2; im = 0; }
803
805 void getRoot2( real_type & re, real_type & im ) const { get_root2( re, im ); }
806
810 void
812 { r = complex_type(m_r2,0); }
813
815 void getRoot2( complex_type & r ) const { get_root2( r ); }
816
824 eval( real_type x ) const
825 { return evalPoly( m_ABCD, 3, x ); }
826
835 { return evalPolyC( m_ABCD, 3, x ); }
836
844 void
845 eval( real_type x, real_type & p, real_type & dp ) const {
846 evalPolyDPoly( m_ABCD, 3, x, p, dp );
847 }
848
852 void
853 info( ostream_type & s ) const;
854
858 bool
859 check( ostream_type & s ) const;
860 };
861
862 // - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
863 /*\
864 | ___ _ _
865 | / _ \ _ _ __ _ _ __| |_(_) ___
866 | | | | | | | |/ _` | '__| __| |/ __|
867 | | |_| | |_| | (_| | | | |_| | (__
868 | \__\_\\__,_|\__,_|_| \__|_|\___|
869 |
870 | A * x^4 + B * x^3 + C * x^2 + D * x + E
871 \*/
950 class Quartic {
951 real_type m_ABCDE[5]{0,0,0,0,0};
952 real_type m_r0{0}, m_r1{0}, m_r2{0},m_r3{0};
953 integer m_iter{0}, m_nreal{0}, m_ncplx{0};
954
955 void find_roots();
956
957 bool cplx0() const { return m_ncplx > 0; }
958 bool cplx1() const { return m_ncplx > 0; }
959 bool cplx2() const { return m_ncplx > 2; }
960 bool cplx3() const { return m_ncplx > 2; }
961
962 public:
963
966 real_type a,
967 real_type b,
968 real_type c,
969 real_type d,
970 real_type e
971 ) {
972 using std::isfinite;
973 real_type & A{m_ABCDE[0]};
974 real_type & B{m_ABCDE[1]};
975 real_type & C{m_ABCDE[2]};
976 real_type & D{m_ABCDE[3]};
977 real_type & E{m_ABCDE[4]};
978 A = a; B = b; C = c; D = d; E = e;
979 // find roots only on finite values
980 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) && isfinite(e) ) {
981 find_roots();
982 }
983 }
984
995 void
997 real_type a,
998 real_type b,
999 real_type c,
1000 real_type d,
1001 real_type e
1002 ) {
1003 using std::isfinite;
1004 real_type & A{m_ABCDE[0]};
1005 real_type & B{m_ABCDE[1]};
1006 real_type & C{m_ABCDE[2]};
1007 real_type & D{m_ABCDE[3]};
1008 real_type & E{m_ABCDE[4]};
1009 A = a; B = b; C = c; D = d; E = e;
1010 m_iter = 0;
1011 m_nreal = 0;
1012 m_ncplx = 0;
1013 // find roots only on finite values
1014 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) && isfinite(e) ) {
1015 find_roots();
1016 }
1017 }
1018
1022 integer num_roots() const { return m_nreal+m_ncplx; }
1023
1025 integer numRoots() const { return m_nreal+m_ncplx; }
1026
1030 integer num_real_roots() const { return m_nreal; }
1031
1033 integer numRealRoots() const { return m_nreal; }
1034
1038 integer num_complex_roots() const { return m_ncplx; }
1039
1041 integer numComplexRoots() const { return m_ncplx; }
1042
1050
1052 integer getRealRoots( real_type r[] ) const { return get_real_roots(r); }
1053
1061
1064
1072
1075
1085
1087 integer getRootsInRange( real_type a, real_type b, real_type r[] ) const { return get_roots_in_range( a, b, r ); }
1088
1098
1101
1105 real_type real_root0() const { return m_r0; }
1106
1110 real_type real_root1() const { return m_r1; }
1111
1115 real_type real_root2() const { return m_r2; }
1116
1120 real_type real_root3() const { return m_r3; }
1121
1126 root0() const
1127 { return cplx0() ? complex_type(m_r0,m_r1) : complex_type(m_r0,0); }
1128
1133 root1() const
1134 { return cplx1() ? complex_type(m_r0,-m_r1) : complex_type(m_r1,0); }
1135
1140 root2() const
1141 { return cplx2() ? complex_type(m_r2,m_r3) : complex_type(m_r2,0); }
1142
1147 root3() const
1148 { return cplx3() ? complex_type(m_r2,-m_r3) : complex_type(m_r3,0); }
1149
1153 void
1154 get_root0( real_type & re, real_type & im ) const {
1155 if ( cplx0() ) { re = m_r0; im = m_r1; }
1156 else { re = m_r0; im = 0; }
1157 }
1158
1160 void getRoot0( real_type & re, real_type & im ) const { get_root0( re, im ); }
1161
1165 void
1167 if ( cplx0() ) r = complex_type(m_r0,m_r1);
1168 else r = complex_type(m_r0,0);
1169 }
1170
1172 void getRoot0( complex_type & r ) const { get_root0( r ); }
1173
1177 void
1178 get_root1( real_type & re, real_type & im ) const {
1179 if ( cplx1() ) { re = m_r0; im = -m_r1; }
1180 else { re = m_r1; im = 0; }
1181 }
1182
1184 void getRoot1( real_type & re, real_type & im ) const { get_root1( re, im ); }
1185
1189 void
1191 if ( cplx1() ) r = complex_type(m_r0,-m_r1);
1192 else r = complex_type(m_r1,0);
1193 }
1194
1196 void getRoot1( complex_type & r ) const { get_root1( r ); }
1197
1201 void
1202 get_root2( real_type & re, real_type & im ) const {
1203 if ( cplx2() ) { re = m_r2; im = m_r3; }
1204 else { re = m_r2; im = 0; }
1205 }
1206
1208 void getRoot2( real_type & re, real_type & im ) const { get_root2( re, im ); }
1209
1213 void
1215 if ( cplx2() ) r = complex_type(m_r2,m_r3);
1216 else r = complex_type(m_r2,0);
1217 }
1218
1220 void getRoot2( complex_type & r ) const { get_root2( r ); }
1221
1225 void
1226 get_root3( real_type & re, real_type & im ) const {
1227 if ( cplx3() ) { re = m_r2; im = -m_r3; }
1228 else { re = m_r3; im = 0; }
1229 }
1230
1232 void getRoot3( real_type & re, real_type & im ) const { get_root3( re, im ); }
1233
1237 void
1239 if ( cplx3() ) r = complex_type(m_r2,-m_r3);
1240 else r = complex_type(m_r3,0);
1241 }
1242
1244 void getRoot3( complex_type & r ) const { get_root3( r ); }
1245
1252 real_type
1253 eval( real_type x ) const
1254 { return evalPoly( m_ABCDE, 4, x ); }
1255
1264 { return evalPolyC( m_ABCDE, 4, x ); }
1265
1273 void
1274 eval( real_type x, real_type & p, real_type & dp ) const {
1275 evalPolyDPoly( m_ABCDE, 4, x, p, dp );
1276 }
1277
1281 void
1282 info( ostream_type & s ) const;
1283
1287 bool
1288 check( ostream_type & s ) const;
1289
1290 };
1291
1292 /*\
1293 | _ _ _ _ _
1294 | | | | | |_(_) |___
1295 | | | | | __| | / __|
1296 | | |_| | |_| | \__ \
1297 | \___/ \__|_|_|___/
1298 \*/
1299
1300 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1301
1302 // x^3 + a*x^2 + b*x + c
1303 static
1304 inline
1305 real_type
1306 evalMonicCubic(
1307 real_type x,
1308 real_type a,
1309 real_type b,
1310 real_type c
1311 ) {
1312 real_type p;
1313 p = x + a;
1314 p = p * x + b;
1315 p = p * x + c;
1316 return p;
1317 }
1318
1319 static
1320 inline
1321 void
1322 evalMonicCubic(
1323 real_type x,
1324 real_type a,
1325 real_type b,
1326 real_type c,
1327 real_type & p,
1328 real_type & dp
1329 ) {
1330 p = x + a;
1331 dp = x + p;
1332 p = p * x + b;
1333 dp = dp * x + p;
1334 p = p * x + c;
1335 }
1336
1337 // 3*x^2 + 2*a*x + b
1338 // 6*x + 2*a
1339 static
1340 inline
1341 void
1342 evalMonicCubic(
1343 real_type x,
1344 real_type a,
1345 real_type b,
1346 real_type c,
1347 real_type & p,
1348 real_type & dp,
1349 real_type & ddp
1350 ) {
1351 p = x + a;
1352 dp = x + p; // 2*x + a
1353 p = p * x + b; // x^2 + a * x + b
1354 ddp = 2*(x + dp);
1355 dp = dp * x + p;
1356 p = p * x + c;
1357 }
1358
1359 // x^4 + a*x^3 + b*x^2 + c*x + d
1360 static
1361 inline
1362 real_type
1363 evalMonicQuartic(
1364 real_type x,
1365 real_type a,
1366 real_type b,
1367 real_type c,
1368 real_type d
1369 ) {
1370 real_type p;
1371 p = x + a; // x + a
1372 p = p * x + b; // x^2+ a*x + b
1373 p = p * x + c; // x^3+ a*x^2 + b*x + c
1374 p = p * x + d; // x^4+ a*x^3 + b*x^2 + c*x + d
1375 return p;
1376 }
1377
1378 static
1379 inline
1380 void
1381 evalMonicQuartic(
1382 real_type x,
1383 real_type a,
1384 real_type b,
1385 real_type c,
1386 real_type d,
1387 real_type & p,
1388 real_type & dp
1389 ) {
1390 p = x + a; // x + a
1391 dp = x + p; // 2*x + a
1392 p = p * x + b; // x^2+ a*x + b
1393 dp = dp * x + p; // 3*x^2 + 2*a*x + b
1394 p = p * x + c; // x^3+ a*x^2 + b*x + c
1395 dp = dp * x + p; // 4*x^3 + 3*a*x^2 + 2*b*x + c
1396 p = p * x + d; // x^4+ a*x^3 + b*x^2 + c*x + d
1397 }
1398
1399 static
1400 inline
1401 void
1402 evalMonicQuartic(
1403 real_type x,
1404 real_type a,
1405 real_type b,
1406 real_type c,
1407 real_type d,
1408 real_type & p,
1409 real_type & dp,
1410 real_type & ddp
1411 ) {
1412 // p_{n+1}(x) = x * p_{n}(x) + b_{n}
1413 // p'_{n+1}(x) = x * p'_{n}(x) + p_{n}(x)
1414 // p''_{n+1}(x) = x * p''_{n}(x) + 2*p'_{n}(x)
1415 // ddp = 0;
1416 // dp = 1;
1417 p = x + a; // x + a
1418
1419 ddp = 2;
1420 dp = x + p;
1421 p = p * x + b;
1422
1423 ddp = ddp * x + 2 * dp;
1424 dp = dp * x + p;
1425 p = p * x + c;
1426
1427 ddp = ddp * x + 2 * dp;
1428 dp = dp * x + p;
1429 p = p * x + d;
1430 }
1431
1432 // x^3 + a*x^2 + b*x + c
1433 static
1434 inline
1435 real_type
1436 eval_monic_cubic(
1437 real_type x,
1438 real_type a,
1439 real_type b,
1440 real_type c
1441 ) {
1442 return evalMonicCubic( x, a, b, c );
1443 }
1444
1445 static
1446 inline
1447 void
1448 eval_monic_cubic(
1449 real_type x,
1450 real_type a,
1451 real_type b,
1452 real_type c,
1453 real_type & p,
1454 real_type & dp
1455 ) {
1456 evalMonicCubic( x, a, b, c, p, dp );
1457 }
1458
1459 // 3*x^2 + 2*a*x + b
1460 // 6*x + 2*a
1461 static
1462 inline
1463 void
1464 eval_monic_cubic(
1465 real_type x,
1466 real_type a,
1467 real_type b,
1468 real_type c,
1469 real_type & p,
1470 real_type & dp,
1471 real_type & ddp
1472 ) {
1473 evalMonicCubic( x, a, b, c, p, dp, ddp );
1474 }
1475
1476 // x^4 + a*x^3 + b*x^2 + c*x + d
1477 static
1478 inline
1479 real_type
1480 eval_monic_quartic(
1481 real_type x,
1482 real_type a,
1483 real_type b,
1484 real_type c,
1485 real_type d
1486 ) {
1487 return evalMonicQuartic( x, a, b, c, d );
1488 }
1489
1490 static
1491 inline
1492 void
1493 eval_monic_quartic(
1494 real_type x,
1495 real_type a,
1496 real_type b,
1497 real_type c,
1498 real_type d,
1499 real_type & p,
1500 real_type & dp
1501 ) {
1502 evalMonicQuartic( x, a, b, c, d, p, dp );
1503 }
1504
1505 static
1506 inline
1507 void
1508 eval_monic_quartic(
1509 real_type x,
1510 real_type a,
1511 real_type b,
1512 real_type c,
1513 real_type d,
1514 real_type & p,
1515 real_type & dp,
1516 real_type & ddp
1517 ) {
1518 evalMonicQuartic( x, a, b, c, d, p, dp, ddp );
1519 }
1520 #endif
1521}
1522
1523#endif
void getRoot1(real_type &re, real_type &im) const
alias of get_root1
Definition PolynomialRoots.hh:785
bool complexRoot() const
alias of complex_root
Definition PolynomialRoots.hh:630
integer get_real_roots(real_type r[]) const
complex_type root0() const
Definition PolynomialRoots.hh:736
void get_root2(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:801
integer getRootsInRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_range
Definition PolynomialRoots.hh:699
integer getPositiveRoots(real_type r[]) const
alias of get_positive_roots
Definition PolynomialRoots.hh:671
complex_type root2() const
Definition PolynomialRoots.hh:750
real_type real_root2() const
Definition PolynomialRoots.hh:730
Cubic()
Definition PolynomialRoots.hh:565
real_type real_root0() const
Definition PolynomialRoots.hh:720
integer getRealRoots(real_type r[]) const
alias of get_real_roots
Definition PolynomialRoots.hh:658
void getRoot2(real_type &re, real_type &im) const
alias of get_root2
Definition PolynomialRoots.hh:805
void setup(real_type a, real_type b, real_type c, real_type d)
Definition PolynomialRoots.hh:599
void eval(real_type x, real_type &p, real_type &dp) const
Definition PolynomialRoots.hh:845
integer get_roots_in_range(real_type a, real_type b, real_type r[]) const
complex_type root1() const
Definition PolynomialRoots.hh:743
integer numRoots() const
alias of num_roots
Definition PolynomialRoots.hh:622
complex_type eval(complex_type x) const
Definition PolynomialRoots.hh:834
void getRoot0(complex_type &r) const
alias of get_root0
Definition PolynomialRoots.hh:773
real_type real_root1() const
Definition PolynomialRoots.hh:725
void getRoot1(complex_type &r) const
alias of get_root1
Definition PolynomialRoots.hh:795
bool doubleRoot() const
alias of double_root
Definition PolynomialRoots.hh:638
void get_root0(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:757
real_type eval(real_type x) const
Definition PolynomialRoots.hh:824
integer getRootsInOpenRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_open_range
Definition PolynomialRoots.hh:714
bool complex_root() const
Definition PolynomialRoots.hh:627
void info(ostream_type &s) const
integer get_negative_roots(real_type r[]) const
void get_root1(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:779
bool check(ostream_type &s) const
integer getNegativeRoots(real_type r[]) const
alias of get_negative_roots
Definition PolynomialRoots.hh:684
integer get_positive_roots(real_type r[]) const
void get_root0(complex_type &r) const
Definition PolynomialRoots.hh:769
bool double_root() const
Definition PolynomialRoots.hh:635
void getRoot0(real_type &re, real_type &im) const
alias of get_root0
Definition PolynomialRoots.hh:763
bool tripleRoot() const
alias of triple_root
Definition PolynomialRoots.hh:646
Cubic(real_type a, real_type b, real_type c, real_type d)
Definition PolynomialRoots.hh:576
void get_root2(complex_type &r) const
Definition PolynomialRoots.hh:811
integer num_roots() const
Definition PolynomialRoots.hh:619
integer get_roots_in_open_range(real_type a, real_type b, real_type r[]) const
void getRoot2(complex_type &r) const
alias of get_root2
Definition PolynomialRoots.hh:815
bool triple_root() const
Definition PolynomialRoots.hh:643
void get_root1(complex_type &r) const
Definition PolynomialRoots.hh:791
integer get_negative_roots(real_type r[]) const
void getRoot0(real_type &re, real_type &im) const
alias of get_root0
Definition PolynomialRoots.hh:376
void get_root1(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:398
complex_type eval(complex_type x) const
Definition PolynomialRoots.hh:437
integer get_real_roots(real_type r[]) const
integer num_roots() const
Definition PolynomialRoots.hh:258
bool double_root() const
Definition PolynomialRoots.hh:274
bool complex_root() const
Definition PolynomialRoots.hh:266
real_type real_root0() const
Definition PolynomialRoots.hh:345
integer get_roots_in_range(real_type a, real_type b, real_type r[]) const
complex_type root0() const
Definition PolynomialRoots.hh:355
real_type real_root1() const
Definition PolynomialRoots.hh:350
void get_root0(complex_type &r) const
Definition PolynomialRoots.hh:385
integer getRootsInRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_range
Definition PolynomialRoots.hh:324
integer get_roots_in_open_range(real_type a, real_type b, real_type r[]) const
complex_type root1() const
Definition PolynomialRoots.hh:360
Quadratic(real_type a, real_type b, real_type c)
Definition PolynomialRoots.hh:218
void getRoot0(complex_type &r) const
alias of get_root0
Definition PolynomialRoots.hh:389
bool complexRoot() const
alias of complex_root
Definition PolynomialRoots.hh:269
void getRoot1(complex_type &r) const
alias of get_root1
Definition PolynomialRoots.hh:418
void getRoot1(real_type &re, real_type &im) const
alias of get_root1
Definition PolynomialRoots.hh:405
Quadratic()
Definition PolynomialRoots.hh:206
void setup(real_type a, real_type b, real_type c)
Definition PolynomialRoots.hh:240
void get_root0(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:369
real_type eval(real_type x) const
Definition PolynomialRoots.hh:427
integer getPositiveRoots(real_type r[]) const
alias of get_positive_roots
Definition PolynomialRoots.hh:299
integer getRootsInOpenRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_open_range
Definition PolynomialRoots.hh:339
bool check(ostream_type &s) const
integer get_positive_roots(real_type r[]) const
integer getNegativeRoots(real_type r[]) const
alias of get_negative_roots
Definition PolynomialRoots.hh:310
integer getRealRoots(real_type r[]) const
alias of get_real_roots
Definition PolynomialRoots.hh:288
void get_root1(complex_type &r) const
Definition PolynomialRoots.hh:414
bool doubleRoot() const
alias of double_root
Definition PolynomialRoots.hh:277
integer numRoots() const
alias of num_roots
Definition PolynomialRoots.hh:261
void eval(real_type x, real_type &p, real_type &dp) const
Definition PolynomialRoots.hh:448
void info(ostream_type &s) const
void getRoot3(complex_type &r) const
alias of get_root3
Definition PolynomialRoots.hh:1244
real_type real_root1() const
Definition PolynomialRoots.hh:1110
integer getPositiveRoots(real_type r[]) const
alias of get_positive_roots
Definition PolynomialRoots.hh:1063
integer get_roots_in_range(real_type a, real_type b, real_type r[]) const
integer numComplexRoots() const
alias of num_complex_root
Definition PolynomialRoots.hh:1041
void getRoot0(complex_type &r) const
alias of get_root0
Definition PolynomialRoots.hh:1172
integer getRootsInOpenRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_open_range
Definition PolynomialRoots.hh:1100
Quartic()
Definition PolynomialRoots.hh:964
integer num_complex_roots() const
Definition PolynomialRoots.hh:1038
void getRoot2(complex_type &r) const
alias of get_root2
Definition PolynomialRoots.hh:1220
void get_root2(complex_type &r) const
Definition PolynomialRoots.hh:1214
real_type real_root3() const
Definition PolynomialRoots.hh:1120
void get_root0(complex_type &r) const
Definition PolynomialRoots.hh:1166
integer get_positive_roots(real_type r[]) const
integer get_roots_in_open_range(real_type a, real_type b, real_type r[]) const
void info(ostream_type &s) const
void get_root2(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:1202
void get_root3(complex_type &r) const
Definition PolynomialRoots.hh:1238
bool check(ostream_type &s) const
complex_type root0() const
Definition PolynomialRoots.hh:1126
void getRoot2(real_type &re, real_type &im) const
alias of get_root2
Definition PolynomialRoots.hh:1208
integer numRoots() const
alias of num_roots
Definition PolynomialRoots.hh:1025
integer getRootsInRange(real_type a, real_type b, real_type r[]) const
alias of get_roots_in_range
Definition PolynomialRoots.hh:1087
integer getRealRoots(real_type r[]) const
alias of get_real_roots
Definition PolynomialRoots.hh:1052
void get_root1(complex_type &r) const
Definition PolynomialRoots.hh:1190
Quartic(real_type a, real_type b, real_type c, real_type d, real_type e)
Definition PolynomialRoots.hh:965
void getRoot0(real_type &re, real_type &im) const
alias of get_root0
Definition PolynomialRoots.hh:1160
integer get_real_roots(real_type r[]) const
void get_root3(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:1226
void getRoot3(real_type &re, real_type &im) const
alias of get_root3
Definition PolynomialRoots.hh:1232
integer num_real_roots() const
Definition PolynomialRoots.hh:1030
complex_type eval(complex_type x) const
Definition PolynomialRoots.hh:1263
real_type eval(real_type x) const
Definition PolynomialRoots.hh:1253
void getRoot1(complex_type &r) const
alias of get_root1
Definition PolynomialRoots.hh:1196
complex_type root3() const
Definition PolynomialRoots.hh:1147
integer numRealRoots() const
alias of num_real_roots
Definition PolynomialRoots.hh:1033
real_type real_root2() const
Definition PolynomialRoots.hh:1115
void eval(real_type x, real_type &p, real_type &dp) const
Definition PolynomialRoots.hh:1274
void get_root0(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:1154
complex_type root2() const
Definition PolynomialRoots.hh:1140
complex_type root1() const
Definition PolynomialRoots.hh:1133
real_type real_root0() const
Definition PolynomialRoots.hh:1105
void get_root1(real_type &re, real_type &im) const
Definition PolynomialRoots.hh:1178
integer get_negative_roots(real_type r[]) const
void setup(real_type a, real_type b, real_type c, real_type d, real_type e)
Definition PolynomialRoots.hh:996
integer num_roots() const
Definition PolynomialRoots.hh:1022
integer getNegativeRoots(real_type r[]) const
alias of get_negative_roots
Definition PolynomialRoots.hh:1074
void getRoot1(real_type &re, real_type &im) const
alias of get_root1
Definition PolynomialRoots.hh:1184
Definition PolynomialRoots-Jenkins-Traub.cc:57
int roots(real_type const *op, integer Degree, real_type *zeror, real_type *zeroi)
Definition PolynomialRoots-Jenkins-Traub.cc:680
std::complex< real_type > complex_type
complex type numbers
Definition PolynomialRoots-Utils.hh:50
int integer
integer type numbers
Definition PolynomialRoots-Utils.hh:49
std::basic_ostream< char > ostream_type
outoput stream type
Definition PolynomialRoots-Utils.hh:51
double real_type
real type numbers
Definition PolynomialRoots-Utils.hh:48
std::basic_istream< char > istream_type
input stream type
Definition PolynomialRoots-Utils.hh:52