92 for(k = 1; k < 4; k++ ) { p[k] = p[k]/p[0]; }
97 b = 0.5*( x*( t/1.5 - p[2] ) + p[3] );
104 d = std::pow( (std::sqrt(d) + std::fabs(b) ), 1.0/3.0 );
108 if( b > 0. ) { b = -d; }
112 d = std::sqrt(0.75)*(b - c);
118 if( ( b > 0. && x <= 0. ) || ( b < 0. && x > 0. ) )
135 if( b == 0. ) { d = std::atan(1.0)/1.5; }
136 else { d = std::atan( std::sqrt(-d)/std::fabs(b) )/3.0; }
138 if( b < 0. ) { b = std::sqrt(t)*2.0; }
139 else { b = -2.0*std::sqrt(t); }
142 t = -std::sqrt(0.75)*std::sin(d)*b - 0.5*c;
147 if( std::fabs(c) > std::fabs(t) ) { r[1][3] = c; }
153 if( std::fabs(d) > std::fabs(t) ) { r[1][2] = d; }
161 for(k = 1; k < 4; k++ ) { r[2][k] = 0.; }
179 for( k = 1; k < 5; k++) { p[k] = p[k]/p[0]; }
186 b = p[3] + b*( c - p[2] );
188 c = p[4] + e*( e*a - p[3] );
192 p[2] = (p[1]*p[1]-c)*0.25;
199 for( k = 1; k < 4; k++ )
201 if( r[2][k] == 0. && r[1][k] > 0 )
206 if ( a >= 0. && b >= 0.) { p[1] = std::sqrt(d); }
207 else if( a <= 0. && b <= 0.) { p[1] = std::sqrt(d); }
208 else { p[1] = -std::sqrt(d); }
210 b = 0.5*( a + b/p[1] );
215 for( i = 1; i < 3; i++ )
217 for( j = 1; j < 3; j++ ) { r[j][i+2] = r[j][i]; }
223 for( i = 1; i < 5; i++ ) { r[1][i] = r[1][i] - e; }
235 if( d > 0. ) { p[1] = std::sqrt(d); }
239 if( p[1] > 0.) { b = std::sqrt(p[2])*2.0 + p[1]; }
240 else { b = -std::sqrt(p[2])*2.0 + p[1]; }
242 if( b != 0.) { p[1] = 0; }
245 for(k = 1; k < 5; k++ )
257 for( k = 1; k < 3; k++ )
259 for( j = 1; j < 3; j++ ) { r[j][k+2] = r[j][k]; }
265 for( k = 1; k < 5; k++ ) { r[1][k] = r[1][k] - e; }
279 G4int k, noReRoots = 0;
281 for( k = 0; k < 4; k++ ) { reRoot[k] =
DBL_MAX; }
285 for( k = 1; k < 5; k++) { p[k] = p[k]/p[0]; }
297 p[3] = 4*a2*a0 - a1*a1 - a3*a3*a0;
301 for( k = 1; k < 4; k++ )
311 for( k = 1; k < 4; k++ )
313 if ( reRoot[k] < y1 ) { y1 = reRoot[k]; }
316 R2 = 0.25*a3*a3 - a2 + y1;
317 b = 0.25*(4*a3*a2 - 8*a1 - a3*a3*a3);
318 c = 0.75*a3*a3 - 2*a2;
331 r[1][1] = -0.25*a3 + 0.5*R + 0.5*D;
332 r[1][2] = -0.25*a3 + 0.5*R - 0.5*D;
339 r[1][1] = -0.25*a3 + 0.5*R;
340 r[1][2] = -0.25*a3 + 0.5*R;
347 r[1][3] = -0.25*a3 - 0.5*R + 0.5*E;
348 r[1][4] = -0.25*a3 - 0.5*R - 0.5*E;
355 r[1][3] = -0.25*a3 - 0.5*R;
356 r[1][4] = -0.25*a3 - 0.5*R;
367 r[1][1] = -0.25*a3 + 0.5*real(CD);
368 r[1][2] = -0.25*a3 - 0.5*real(CD);
369 r[2][1] = 0.5*R + 0.5*imag(CD);
370 r[2][2] = 0.5*R - 0.5*imag(CD);
374 r[1][3] = -0.25*a3 + 0.5*real(CE);
375 r[1][4] = -0.25*a3 - 0.5*real(CE);
376 r[2][3] = -0.5*R + 0.5*imag(CE);
377 r[2][4] = -0.5*R - 0.5*imag(CE);
383 D2 = c + std::sqrt(d);
384 E2 = c - std::sqrt(d);
389 r[1][1] = -0.25*a3 + 0.5*R + 0.5*D;
390 r[1][2] = -0.25*a3 + 0.5*R - 0.5*D;
397 r[1][1] = -0.25*a3 + 0.5*R;
398 r[1][2] = -0.25*a3 + 0.5*R;
405 r[1][3] = -0.25*a3 - 0.5*R + 0.5*E;
406 r[1][4] = -0.25*a3 - 0.5*R - 0.5*E;
413 r[1][3] = -0.25*a3 - 0.5*R;
414 r[1][4] = -0.25*a3 - 0.5*R;
425 r[1][1] = -0.25*a3 + 0.5*real(CD);
426 r[1][2] = -0.25*a3 - 0.5*real(CD);
427 r[2][1] = 0.5*R + 0.5*imag(CD);
428 r[2][2] = 0.5*R - 0.5*imag(CD);
433 r[1][3] = -0.25*a3 + 0.5*real(CE);
434 r[1][4] = -0.25*a3 - 0.5*real(CE);
435 r[2][3] = -0.5*R + 0.5*imag(CE);
436 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])