55 b = -p[1] / p[0] / 2.;
93 for(k = 1; k < 4; k++)
101 b = 0.5 * (x * (t / 1.5 - p[2]) + p[3]);
102 t = (t - p[2]) / 3.0;
108 d = std::pow((std::sqrt(d) + std::fabs(b)), 1.0 / 3.0);
122 d = std::sqrt(0.75) * (b - c);
128 if((b > 0. && x <= 0.) || (b < 0. && x > 0.))
147 d = std::atan(1.0) / 1.5;
151 d = std::atan(std::sqrt(-d) / std::fabs(b)) / 3.0;
156 b = std::sqrt(t) * 2.0;
160 b = -2.0 * std::sqrt(t);
164 t = -std::sqrt(0.75) * std::sin(d) * b - 0.5 * c;
169 if(std::fabs(c) > std::fabs(t))
178 if(std::fabs(d) > std::fabs(t))
189 for(k = 1; k < 4; k++)
210 for(k = 1; k < 5; k++)
220 b = p[3] + b * (c - p[2]);
222 c = p[4] + e * (e * a - p[3]);
226 p[2] = (p[1] * p[1] - c) * 0.25;
227 p[3] = b * b / (-64.0);
233 for(k = 1; k < 4; k++)
235 if(r[2][k] == 0. && r[1][k] > 0)
240 if(a >= 0. && b >= 0.)
244 else if(a <= 0. && b <= 0.)
250 p[1] = -std::sqrt(d);
253 b = 0.5 * (a + b / p[1]);
258 for(i = 1; i < 3; i++)
260 for(j = 1; j < 3; j++)
262 r[j][i + 2] = r[j][i];
269 for(i = 1; i < 5; i++)
271 r[1][i] = r[1][i] - e;
293 b = std::sqrt(p[2]) * 2.0 + p[1];
297 b = -std::sqrt(p[2]) * 2.0 + p[1];
306 for(k = 1; k < 5; k++)
318 for(k = 1; k < 3; k++)
320 for(j = 1; j < 3; j++)
322 r[j][k + 2] = r[j][k];
329 for(k = 1; k < 5; k++)
331 r[1][k] = r[1][k] - e;
346 G4int k, noReRoots = 0;
348 for(k = 0; k < 4; k++)
355 for(k = 1; k < 5; k++)
369 p[2] = a1 * a3 - 4 *
a0;
370 p[3] = 4 * a2 *
a0 - a1 * a1 - a3 * a3 *
a0;
374 for(k = 1; k < 4; k++)
385 for(k = 1; k < 4; k++)
393 R2 = 0.25 * a3 * a3 - a2 + y1;
394 b = 0.25 * (4 * a3 * a2 - 8 * a1 - a3 * a3 * a3);
395 c = 0.75 * a3 * a3 - 2 * a2;
397 d = 4 * y1 * y1 - 16 *
a0;
408 r[1][1] = -0.25 * a3 + 0.5 * R + 0.5 *
D;
409 r[1][2] = -0.25 * a3 + 0.5 * R - 0.5 *
D;
416 r[1][1] = -0.25 * a3 + 0.5 * R;
417 r[1][2] = -0.25 * a3 + 0.5 * R;
424 r[1][3] = -0.25 * a3 - 0.5 * R + 0.5 * E;
425 r[1][4] = -0.25 * a3 - 0.5 * R - 0.5 * E;
432 r[1][3] = -0.25 * a3 - 0.5 * R;
433 r[1][4] = -0.25 * a3 - 0.5 * R;
444 r[1][1] = -0.25 * a3 + 0.5 * real(CD);
445 r[1][2] = -0.25 * a3 - 0.5 * real(CD);
446 r[2][1] = 0.5 * R + 0.5 * imag(CD);
447 r[2][2] = 0.5 * R - 0.5 * imag(CD);
451 r[1][3] = -0.25 * a3 + 0.5 * real(CE);
452 r[1][4] = -0.25 * a3 - 0.5 * real(CE);
453 r[2][3] = -0.5 * R + 0.5 * imag(CE);
454 r[2][4] = -0.5 * R - 0.5 * imag(CE);
460 D2 = c + std::sqrt(d);
461 E2 = c - std::sqrt(d);
466 r[1][1] = -0.25 * a3 + 0.5 * R + 0.5 *
D;
467 r[1][2] = -0.25 * a3 + 0.5 * R - 0.5 *
D;
474 r[1][1] = -0.25 * a3 + 0.5 * R;
475 r[1][2] = -0.25 * a3 + 0.5 * R;
482 r[1][3] = -0.25 * a3 - 0.5 * R + 0.5 * E;
483 r[1][4] = -0.25 * a3 - 0.5 * R - 0.5 * E;
490 r[1][3] = -0.25 * a3 - 0.5 * R;
491 r[1][4] = -0.25 * a3 - 0.5 * R;
502 r[1][1] = -0.25 * a3 + 0.5 * real(CD);
503 r[1][2] = -0.25 * a3 - 0.5 * real(CD);
504 r[2][1] = 0.5 * R + 0.5 * imag(CD);
505 r[2][2] = 0.5 * R - 0.5 * imag(CD);
510 r[1][3] = -0.25 * a3 + 0.5 * real(CE);
511 r[1][4] = -0.25 * a3 - 0.5 * real(CE);
512 r[2][3] = -0.5 * R + 0.5 * imag(CE);
513 r[2][4] = -0.5 * R - 0.5 * imag(CE);
std::complex< G4double > G4complex
G4int CubicRoots(G4double p[5], G4double r[3][5])
G4int QuarticRoots(G4double p[5], G4double r[3][5])
G4int QuadRoots(G4double p[5], G4double r[3][5])
G4int BiquadRoots(G4double p[5], G4double r[3][5])