#include <cubic.h>
Definition at line 18 of file cubic.h.
◆ double_complex
◆ Cubic() [1/2]
Definition at line 45 of file cubic.h.
45: da(0.0), db(0.0), dc(0.0), dd(0.0), s_dxzero(0) {}
◆ Cubic() [2/2]
Cubic::Cubic |
( |
double |
fa, |
|
|
double |
fb, |
|
|
double |
fc, |
|
|
double |
fd |
|
) |
| |
|
inline |
Definition at line 46 of file cubic.h.
47 : da(fa), db(fb), dc(fc), dd(fd), s_dxzero(0) {}
◆ a()
double Cubic::a |
( |
void |
| ) |
const |
|
inline |
◆ b()
double Cubic::b |
( |
void |
| ) |
const |
|
inline |
◆ c()
double Cubic::c |
( |
void |
| ) |
const |
|
inline |
◆ d()
double Cubic::d |
( |
void |
| ) |
const |
|
inline |
◆ find_maxmin()
int Cubic::find_maxmin |
( |
double |
xmm[2], |
|
|
double |
ymm[2], |
|
|
int |
s_mm[2] |
|
) |
| const |
Definition at line 122 of file cubic.cpp.
122 {
123 mfunname(
"int Cubic::find_maxmin(double xmm[2], double ymm[2], int s_mm[2]) "
124 "const");
125 double ap = 3 * da;
126 double bp = 2 * db;
127 double cp = dc;
129 s_mm[0] = 0;
130 s_mm[1] = 0;
131 int qz = par.find_zero(xmm);
132 if (qz == 1) {
133 s_mm[0] = 0;
134 }
135 if (qz == 2) {
137 s_mm[0] = 1;
138 s_mm[1] = -1;
139 } else {
140 s_mm[0] = -1;
141 s_mm[1] = 1;
142 }
143 }
144 for (int n = 0; n < qz; ++n) {
146 }
147 return qz;
148}
Referenced by operator<<().
◆ find_real_zero()
int Cubic::find_real_zero |
( |
double |
z[3] | ) |
const |
Definition at line 76 of file cubic.cpp.
76 {
77 mfunname(
"int Cubic::find_real_zero(double z[3]) const");
82 double thresh = 10.0 * DBL_MIN;
83 int q = 0;
84 if (
fabs(zc1.imag()) < thresh ||
85 (zc1.real() != 0.0 &&
fabs(zc1.imag() / zc1.real()) < thresh)) {
86 z[q] = zc1.real();
87 q++;
88 }
89 if (
fabs(zc2.imag()) < thresh ||
90 (zc2.real() != 0.0 &&
fabs(zc2.imag() / zc2.real()) < thresh)) {
91 z[q] = zc2.real();
92 q++;
93 }
94 if (
fabs(zc3.imag()) < thresh ||
95 (zc3.real() != 0.0 &&
fabs(zc3.imag() / zc3.real()) < thresh)) {
96 z[q] = zc3.real();
97 q++;
98 }
99 int n1 = 0, n2 = 0;
100 for (n1 = 0; n1 < q - 1; n1++) {
101 for (n2 = n1; n2 < q; n2++) {
102 if (z[n1] > z[n2]) {
103 double t = z[n1];
104 z[n1] = z[n2];
105 z[n2] = t;
106 }
107 }
108 }
109 for (n1 = 0; n1 < q - 1; n1++) {
110 if ((
fabs(z[n1]) < thresh &&
fabs(z[n2]) < thresh) ||
111 fabs((z[n1] - z[n1 + 1]) / (z[n1] + z[n1 + 1])) < thresh) {
112 for (n2 = n1 + 1; n2 < q - 1; n2++) {
113 z[n2] = z[n2 + 1];
114 }
115 q--;
116 n1--;
117 }
118 }
119 return q;
120}
DoubleAc fabs(const DoubleAc &f)
void find_zero(double_complex &z1, double_complex &z2, double_complex &z3) const
std::complex< double > double_complex
Referenced by operator<<().
◆ find_zero()
Definition at line 25 of file cubic.cpp.
26 {
27 mfunname(
"void Cubic::find_zero(double_complex &z1, double_complex &z2, "
28 "double_complex &z3) const");
30 if (s_dxzero == 0) {
32 double a2 = db / da;
33 double a1 = dc / da;
34 double a0 = dd / da;
35 double Q = (3.0 * a1 - a2 * a2) / 9.0;
36 double R = (9.0 * a2 * a1 - 27.0 * a0 - 2.0 * a2 * a2 * a2) / 54.0;
37 double D = Q * Q * Q + R * R;
41 if (D >= 0.0) {
42 double t = R + sD;
43 if (t > 0.0) {
45 } else if (t < 0.0) {
46 S = -
pow(-t, 1 / 3.0);
47 } else {
48 S = 0.0;
49 }
50 t = R - sD;
51 if (t > 0.0) {
53 } else if (t < 0.0) {
54 T = -
pow(-t, 1 / 3.0);
55 } else {
56 T = 0.0;
57 }
58 } else {
59 S =
pow(R + iu * sD, 1 / 3.0);
60 T =
pow(R - iu * sD, 1 / 3.0);
61 }
62 z1 = -a2 / 3.0 + (S + T);
63 z2 = -a2 / 3.0 - (S + T) / 2.0 + 0.5 * iu *
sqrt(3.0) * (S - T);
64 z3 = -a2 / 3.0 - (S + T) / 2.0 - 0.5 * iu *
sqrt(3.0) * (S - T);
65 t.dz1 = z1;
66 t.dz2 = z2;
67 t.dz3 = z3;
68 t.s_dxzero = 3;
69 } else {
70 z1 = dz1;
71 z2 = dz2;
72 z3 = dz3;
73 }
74}
DoubleAc pow(const DoubleAc &f, double p)
DoubleAc sqrt(const DoubleAc &f)
#define check_econd11a(a, signb, add, stream)
Referenced by find_real_zero(), and operator<<().
◆ put_a()
void Cubic::put_a |
( |
double |
fa | ) |
|
|
inline |
Definition at line 28 of file cubic.h.
28 {
29 da = fa;
30 s_dxzero = 0;
31 }
◆ put_b()
void Cubic::put_b |
( |
double |
fb | ) |
|
|
inline |
Definition at line 32 of file cubic.h.
32 {
33 db = fb;
34 s_dxzero = 0;
35 }
◆ put_c()
void Cubic::put_c |
( |
double |
fc | ) |
|
|
inline |
Definition at line 36 of file cubic.h.
36 {
37 dc = fc;
38 s_dxzero = 0;
39 }
◆ put_d()
void Cubic::put_d |
( |
double |
fd | ) |
|
|
inline |
Definition at line 40 of file cubic.h.
40 {
41 dd = fd;
42 s_dxzero = 0;
43 }
◆ s_xzero()
double Cubic::s_xzero |
( |
void |
| ) |
const |
|
inline |
◆ y()
double Cubic::y |
( |
double |
x | ) |
const |
|
inline |
Definition at line 49 of file cubic.h.
49 {
50 return da * x * x * x + db * x * x + dc * x + dd;
51 }
Referenced by find_maxmin().
The documentation for this class was generated from the following files: