51 typedef long long longint;
52 typedef unsigned long long ulongint;
53 #define qbit_clear(a,b) ((a) & ~((ulongint)1 << (b)))
54 #define qbit_set(a,b) ((a) | ((ulongint)1 << (b)))
185 #define loc_abs(x) ((x) >= 0 ? (x) : -(x))
186 #define dabs(x) (doublereal)loc_abs(x)
191 #define bit_test(a,b) ((a) >> (b) & 1)
192 #define bit_clear(a,b) ((a) & ~((uinteger)1 << (b)))
193 #define bit_set(a,b) ((a) | ((uinteger)1 << (b)))
197 #define F2C_proc_par_types 1
199 typedef int (*U_fp)(...);
209 typedef int (*
S_fp)(...);
211 typedef int (*U_fp)();
231 #ifndef Skip_f2c_Undefs
265 extern "C" {
double sqrt(
double),
sin(
double);}
273 double d__1, d__2, d__3;
274 double equiv_2[3], equiv_5[3];
284 #define y (equiv_2 + 1)
285 #define z__ (equiv_2 + 2)
286 double f1,
f2, f3,
h2, f4,
h4, g1, g2, g3, g4, g5, g6, at, bt,
289 #define yt (equiv_5 + 1)
290 #define zt (equiv_5 + 2)
291 double ph2, cba, rho, est, tet, hxp[3], dxt, dyt, dzt, ang2;
292 #define xyz (equiv_2)
297 double pinv, rest, sint;
298 #define xyzt (equiv_5)
299 extern int gufld_(
double *,
double *);
300 double hnorm, secxs[4], secys[4], seczs[4];
338 for (j = 1; j <= 7; ++j) {
342 pinv = *charge * 2.9979251e-3 / vect[7];
353 bfield->
GetField(vout[1], vout[2], vout[3], f[0], f[1], f[2]);
369 secxs[0] = (b * f[2] - c__ * f[1]) * ph2;
370 secys[0] = (c__ * f[0] - a * f[2]) * ph2;
371 seczs[0] = (a * f[1] - b * f[0]) * ph2;
378 ang2 = d__1 * d__1 + d__2 * d__2 + d__3 * d__3;
379 if (ang2 > 9.86960440109) {
382 dxt = h2 * a + h4 * secxs[0];
383 dyt = h2 * b + h4 * secys[0];
384 dzt = h2 * c__ + h4 * seczs[0];
401 secxs[1] = (bt * f[2] - ct * f[1]) * ph2;
402 secys[1] = (ct * f[0] - at * f[2]) * ph2;
403 seczs[1] = (at * f[1] - bt * f[0]) * ph2;
407 secxs[2] = (bt * f[2] - ct * f[1]) * ph2;
408 secys[2] = (ct * f[0] - at * f[2]) * ph2;
409 seczs[2] = (at * f[1] - bt * f[0]) * ph2;
410 dxt = h__ * (a + secxs[2]);
411 dyt = h__ * (b + secys[2]);
412 dzt = h__ * (c__ + seczs[2]);
416 at = a + secxs[2] * 2.;
417 bt = b + secys[2] * 2.;
418 ct = c__ + seczs[2] * 2.;
421 if (est >
loc_abs(h__) * 2.f) {
427 *
z__ += (c__ + (seczs[0] + seczs[1] + seczs[2]) * .33333333333333331) *
429 *
y += (b + (secys[0] + secys[1] + secys[2]) * .33333333333333331) * h__;
430 *
x += (a + (secxs[0] + secxs[1] + secxs[2]) * .33333333333333331) * h__;
432 secxs[3] = (bt * f[2] - ct * f[1]) * ph2;
433 secys[3] = (ct * f[0] - at * f[2]) * ph2;
434 seczs[3] = (at * f[1] - bt * f[0]) * ph2;
435 a += (secxs[0] + secxs[3] + (secxs[1] + secxs[2]) * 2.) *
437 b += (secys[0] + secys[3] + (secys[1] + secys[2]) * 2.) *
439 c__ += (seczs[0] + seczs[3] + (seczs[1] + seczs[2]) * 2.) *
442 est = (d__1 = secxs[0] + secxs[3] - (secxs[1] + secxs[2]),
loc_abs(d__1)) + (
443 d__2 = secys[0] + secys[3] - (secys[1] + secys[2]),
loc_abs(d__2)) + (
444 d__3 = seczs[0] + seczs[3] - (seczs[1] + seczs[2]),
loc_abs(d__3));
457 if (est < 3.1250000000000001
e-6) {
460 cba = 1. /
sqrt(a * a + b * b + c__ * c__);
471 if (rest >
dabs(*step) * 1
e-5f) {
498 f4 =
sqrt(d__1 * d__1 + d__2 * d__2 + d__3 * d__3);
507 hxp[0] = f2 * vect[6] - f3 * vect[5];
508 hxp[1] = f3 * vect[4] - f1 * vect[6];
509 hxp[2] = f1 * vect[5] - f2 * vect[4];
510 hp = f1 * vect[4] + f2 * vect[5] + f3 * vect[6];
515 d__1 =
sin(tet * .5);
516 cost = d__1 * d__1 * 2.;
520 g3 = (tet - sint) * hp * rho1;
524 vout[1] = vect[1] + (g1 * vect[4] + g2 * hxp[0] + g3 *
f1);
525 vout[2] = vect[2] + (g1 * vect[5] + g2 * hxp[1] + g3 *
f2);
526 vout[3] = vect[3] + (g1 * vect[6] + g2 * hxp[2] + g3 * f3);
527 vout[4] = vect[4] + (g4 * vect[4] + g5 * hxp[0] + g6 *
f1);
528 vout[5] = vect[5] + (g4 * vect[5] + g5 * hxp[1] + g6 *
f2);
529 vout[6] = vect[6] + (g4 * vect[6] + g5 * hxp[2] + g6 * f3);
532 vout[1] = vect[1] + *step * vect[4];
533 vout[2] = vect[2] + *step * vect[5];
534 vout[3] = vect[3] + *step * vect[6];
void gufld_(float *x, float *f)
int grkuta_(double *CHARGE, double *STEP, double *VECT, double *VOUT, const DMagneticFieldMap *bfield)
virtual void GetField(const DVector3 &pos, DVector3 &Bout) const =0
unsigned long int uinteger