20#ifndef POLYNOMIAL_ROOTS_HH
21#define POLYNOMIAL_ROOTS_HH
56 #ifndef DOXYGEN_SHOULD_SKIP_THIS
63 {
return FP_ZERO == std::fpclassify(x); }
225 if ( isfinite(a) && isfinite(b) && isfinite(c) ) {
370 if ( m_cplx ) { re = m_r0; im = m_r1; }
371 else { re = m_r0; im = 0; }
399 if ( m_cplx ) { re = m_r0; im = -m_r1; }
400 else { re = m_r1; im = 0; }
428 {
return evalPoly( m_ABC, 2, x ); }
438 {
return evalPolyC( m_ABC, 2, x ); }
449 evalPolyDPoly( m_ABC, 2, x, p, dp );
582 A = a; B = b; C = c; D = d;
584 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) ) {
610 A = a; B = b; C = c; D = d;
611 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) ) {
758 if ( m_cplx ) { re = m_r0; im = m_r1; }
759 else { re = m_r0; im = 0; }
780 if ( m_cplx ) { re = m_r0; im = -m_r1; }
781 else { re = m_r1; im = 0; }
802 { re = m_r2; im = 0; }
825 {
return evalPoly( m_ABCD, 3, x ); }
835 {
return evalPolyC( m_ABCD, 3, x ); }
846 evalPolyDPoly( m_ABCD, 3, x, p, dp );
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};
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; }
978 A = a; B = b; C = c; D = d; E = e;
980 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) && isfinite(e) ) {
1003 using std::isfinite;
1009 A = a; B = b; C = c; D = d; E = e;
1014 if ( isfinite(a) && isfinite(b) && isfinite(c) && isfinite(d) && isfinite(e) ) {
1155 if ( cplx0() ) { re = m_r0; im = m_r1; }
1156 else { re = m_r0; im = 0; }
1179 if ( cplx1() ) { re = m_r0; im = -m_r1; }
1180 else { re = m_r1; im = 0; }
1203 if ( cplx2() ) { re = m_r2; im = m_r3; }
1204 else { re = m_r2; im = 0; }
1227 if ( cplx3() ) { re = m_r2; im = -m_r3; }
1228 else { re = m_r3; im = 0; }
1254 {
return evalPoly( m_ABCDE, 4, x ); }
1264 {
return evalPolyC( m_ABCDE, 4, x ); }
1275 evalPolyDPoly( m_ABCDE, 4, x, p, dp );
1300 #ifndef DOXYGEN_SHOULD_SKIP_THIS
1423 ddp = ddp * x + 2 * dp;
1427 ddp = ddp * x + 2 * dp;
1442 return evalMonicCubic( x, a, b, c );
1456 evalMonicCubic( x, a, b, c, p, dp );
1473 evalMonicCubic( x, a, b, c, p, dp, ddp );
1487 return evalMonicQuartic( x, a, b, c, d );
1502 evalMonicQuartic( x, a, b, c, d, p, dp );
1518 evalMonicQuartic( x, a, b, c, d, p, dp, ddp );
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