Split g96 I/O routines from confio.cpp
[gromacs.git] / src / gromacs / linearalgebra / gmx_lapack / slasd5.c
blob4773373116469a8b2e1136f99b452138de4d16c2
1 #include <math.h>
2 #include "../gmx_lapack.h"
4 void
5 F77_FUNC(slasd5,SLASD5)(int *i__,
6 float *d__,
7 float *z__,
8 float *delta,
9 float *rho,
10 float *dsigma,
11 float *work)
13 float b, c__, w, del, tau, delsq;
15 --work;
16 --delta;
17 --z__;
18 --d__;
20 del = d__[2] - d__[1];
21 delsq = del * (d__[2] + d__[1]);
22 if (*i__ == 1) {
23 w = *rho * 4. * (z__[2] * z__[2] / (d__[1] + d__[2] * 3.) - z__[1] *
24 z__[1] / (d__[1] * 3. + d__[2])) / del + 1.;
25 if (w > 0.) {
26 b = delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
27 c__ = *rho * z__[1] * z__[1] * delsq;
29 tau = c__ * 2. / (b + sqrt(fabs(b * b - c__ * 4.)));
31 tau /= d__[1] + sqrt(d__[1] * d__[1] + tau);
32 *dsigma = d__[1] + tau;
33 delta[1] = -tau;
34 delta[2] = del - tau;
35 work[1] = d__[1] * 2. + tau;
36 work[2] = d__[1] + tau + d__[2];
37 } else {
38 b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
39 c__ = *rho * z__[2] * z__[2] * delsq;
41 if (b > 0.) {
42 tau = c__ * -2. / (b + sqrt(b * b + c__ * 4.));
43 } else {
44 tau = (b - sqrt(b * b + c__ * 4.)) / 2.;
47 tau /= d__[2] + sqrt(fabs(d__[2] * d__[2] + tau));
48 *dsigma = d__[2] + tau;
49 delta[1] = -(del + tau);
50 delta[2] = -tau;
51 work[1] = d__[1] + tau + d__[2];
52 work[2] = d__[2] * 2. + tau;
54 } else {
56 b = -delsq + *rho * (z__[1] * z__[1] + z__[2] * z__[2]);
57 c__ = *rho * z__[2] * z__[2] * delsq;
59 if (b > 0.) {
60 tau = (b + sqrt(b * b + c__ * 4.)) / 2.;
61 } else {
62 tau = c__ * 2. / (-b + sqrt(b * b + c__ * 4.));
64 tau /= d__[2] + sqrt(d__[2] * d__[2] + tau);
65 *dsigma = d__[2] + tau;
66 delta[1] = -(del + tau);
67 delta[2] = -tau;
68 work[1] = d__[1] + tau + d__[2];
69 work[2] = d__[2] * 2. + tau;
71 return;