113 for (
int j = 0; j <
n; j++) {
119 for (
int i =
n-1; i > 0; i--) {
125 for (
int k = 0; k < i; k++) {
126 scale = scale + abs(d[k]);
130 for (
int j = 0; j < i; j++) {
139 for (
int k = 0; k < i; k++) {
151 for (
int j = 0; j < i; j++) {
157 for (
int j = 0; j < i; j++) {
160 g =
e[j] +
V[j][j] * f;
161 for (
int k = j+1; k <= i-1; k++) {
168 for (
int j = 0; j < i; j++) {
172 Real hh = f / (h + h);
173 for (
int j = 0; j < i; j++) {
176 for (
int j = 0; j < i; j++) {
179 for (
int k = j; k <= i-1; k++) {
180 V[k][j] -= (f *
e[k] + g * d[k]);
191 for (
int i = 0; i <
n-1; i++) {
196 for (
int k = 0; k <= i; k++) {
197 d[k] =
V[k][i+1] / h;
199 for (
int j = 0; j <= i; j++) {
201 for (
int k = 0; k <= i; k++) {
202 g +=
V[k][i+1] *
V[k][j];
204 for (
int k = 0; k <= i; k++) {
209 for (
int k = 0; k <= i; k++) {
213 for (
int j = 0; j <
n; j++) {
230 for (
int i = 1; i <
n; i++) {
237 Real eps = pow(2.0,-52.0);
238 for (
int l = 0; l <
n; l++) {
242 tst1 = std::max(tst1,abs(d[l]) + abs(
e[l]));
247 if (abs(
e[m]) <= eps*tst1) {
265 Real p = (d[l+1] - g) / (2.0 *
e[l]);
266 Real r =
hypot(p,1.0);
270 d[l] =
e[l] / (p + r);
271 d[l+1] =
e[l] * (p + r);
274 for (
int i = l+2; i <
n; i++) {
288 for (
int i = m-1; i >= l; i--) {
298 p = c * d[i] - s * g;
299 d[i+1] = h + s * (c * g + s * d[i]);
303 for (
int k = 0; k <
n; k++) {
305 V[k][i+1] = s *
V[k][i] + c * h;
306 V[k][i] = c *
V[k][i] - s * h;
309 p = -s * s2 * c3 * el1 *
e[l] / dl1;
315 }
while (abs(
e[l]) > eps*tst1);
323 for (
int i = 0; i <
n-1; i++) {
326 for (
int j = i+1; j <
n; j++) {
335 for (
int j = 0; j <
n; j++) {
356 for (
int m = low+1; m <= high-1; m++) {
361 for (
int i = m; i <= high; i++) {
362 scale = scale + abs(H[i][m-1]);
369 for (
int i = high; i >= m; i--) {
370 ort[i] = H[i][m-1]/scale;
371 h += ort[i] * ort[i];
383 for (
int j = m; j <
n; j++) {
385 for (
int i = high; i >= m; i--) {
389 for (
int i = m; i <= high; i++) {
394 for (
int i = 0; i <= high; i++) {
396 for (
int j = high; j >= m; j--) {
400 for (
int j = m; j <= high; j++) {
404 ort[m] = scale*ort[m];
411 for (
int i = 0; i <
n; i++) {
412 for (
int j = 0; j <
n; j++) {
413 V[i][j] = (i == j ? 1.0 : 0.0);
417 for (
int m = high-1; m >= low+1; m--) {
418 if (H[m][m-1] != 0.0) {
419 for (
int i = m+1; i <= high; i++) {
422 for (
int j = m; j <= high; j++) {
424 for (
int i = m; i <= high; i++) {
425 g += ort[i] *
V[i][j];
428 g = (g / ort[m]) / H[m][m-1];
429 for (
int i = m; i <= high; i++) {
430 V[i][j] += g * ort[i];
441 void cdiv(Real xr, Real xi, Real yr, Real yi) {
443 if (abs(yr) > abs(yi)) {
446 cdivr = (xr + r*xi)/d;
447 cdivi = (xi - r*xr)/d;
451 cdivr = (r*xr + xi)/d;
452 cdivi = (r*xi - xr)/d;
472 Real eps = pow(2.0,-52.0);
474 Real p=0,q=0,r=0,s=0,z=0,t,w,x,y;
479 for (
int i = 0; i < nn; i++) {
480 if ((i < low) || (i > high)) {
484 for (
int j = std::max(i-1,0); j < nn; j++) {
485 norm = norm + abs(H[i][j]);
498 s = abs(H[l-1][l-1]) + abs(H[l][l]);
502 if (abs(H[l][l-1]) < eps * s) {
512 H[
n][
n] = H[
n][
n] + exshift;
520 }
else if (l ==
n-1) {
521 w = H[
n][
n-1] * H[
n-1][
n];
522 p = (H[
n-1][
n-1] - H[
n][
n]) / 2.0;
525 H[
n][
n] = H[
n][
n] + exshift;
526 H[
n-1][
n-1] = H[
n-1][
n-1] + exshift;
548 r = sqrt(p * p+q * q);
554 for (
int j =
n-1; j < nn; j++) {
556 H[
n-1][j] = q * z + p * H[
n][j];
557 H[
n][j] = q * H[
n][j] - p * z;
562 for (
int i = 0; i <=
n; i++) {
564 H[i][
n-1] = q * z + p * H[i][
n];
565 H[i][
n] = q * H[i][
n] - p * z;
570 for (
int i = low; i <= high; i++) {
572 V[i][
n-1] = q * z + p *
V[i][
n];
573 V[i][
n] = q *
V[i][
n] - p * z;
598 w = H[
n][
n-1] * H[
n-1][
n];
605 for (
int i = low; i <=
n; i++) {
608 s = abs(H[
n][
n-1]) + abs(H[
n-1][
n-2]);
623 s = x - w / ((y - x) / 2.0 + s);
624 for (
int i = low; i <=
n; i++) {
641 p = (r * s - w) / H[m+1][m] + H[m][m+1];
642 q = H[m+1][m+1] - z - r - s;
644 s = abs(p) + abs(q) + abs(r);
651 if (abs(H[m][m-1]) * (abs(q) + abs(r)) <
652 eps * (abs(p) * (abs(H[m-1][m-1]) + abs(z) +
653 abs(H[m+1][m+1])))) {
659 for (
int i = m+2; i <=
n; i++) {
668 for (
int k = m; k <=
n-1; k++) {
669 int notlast = (k !=
n-1);
673 r = (notlast ? H[k+2][k-1] : 0.0);
674 x = abs(p) + abs(q) + abs(r);
684 s = sqrt(p * p + q * q + r * r);
692 H[k][k-1] = -H[k][k-1];
703 for (
int j = k; j < nn; j++) {
704 p = H[k][j] + q * H[k+1][j];
706 p = p + r * H[k+2][j];
707 H[k+2][j] = H[k+2][j] - p * z;
709 H[k][j] = H[k][j] - p * x;
710 H[k+1][j] = H[k+1][j] - p * y;
715 for (
int i = 0; i <= std::min(
n,k+3); i++) {
716 p = x * H[i][k] + y * H[i][k+1];
718 p = p + z * H[i][k+2];
719 H[i][k+2] = H[i][k+2] - p * r;
721 H[i][k] = H[i][k] - p;
722 H[i][k+1] = H[i][k+1] - p * q;
727 for (
int i = low; i <= high; i++) {
728 p = x *
V[i][k] + y *
V[i][k+1];
730 p = p + z *
V[i][k+2];
731 V[i][k+2] =
V[i][k+2] - p * r;
733 V[i][k] =
V[i][k] - p;
734 V[i][k+1] =
V[i][k+1] - p * q;
747 for (
n = nn-1;
n >= 0;
n--) {
756 for (
int i =
n-1; i >= 0; i--) {
759 for (
int j = l; j <=
n; j++) {
760 r = r + H[i][j] * H[j][
n];
771 H[i][
n] = -r / (eps * norm);
779 q = (d[i] - p) * (d[i] - p) +
e[i] *
e[i];
780 t = (x * s - z * r) / q;
782 if (abs(x) > abs(z)) {
783 H[i+1][
n] = (-r - w * t) / x;
785 H[i+1][
n] = (-s - y * t) / z;
792 if ((eps * t) * t > 1) {
793 for (
int j = i; j <=
n; j++) {
794 H[j][
n] = H[j][
n] / t;
807 if (abs(H[
n][
n-1]) > abs(H[
n-1][
n])) {
808 H[
n-1][
n-1] = q / H[
n][
n-1];
809 H[
n-1][
n] = -(H[
n][
n] - p) / H[
n][
n-1];
811 cdiv(0.0,-H[
n-1][
n],H[
n-1][
n-1]-p,q);
817 for (
int i =
n-2; i >= 0; i--) {
821 for (
int j = l; j <=
n; j++) {
822 ra = ra + H[i][j] * H[j][
n-1];
823 sa = sa + H[i][j] * H[j][
n];
843 vr = (d[i] - p) * (d[i] - p) +
e[i] *
e[i] - q * q;
844 vi = (d[i] - p) * 2.0 * q;
845 if ((vr == 0.0) && (vi == 0.0)) {
846 vr = eps * norm * (abs(w) + abs(q) +
847 abs(x) + abs(y) + abs(z));
849 cdiv(x*r-z*ra+q*sa,x*s-z*sa-q*ra,vr,vi);
852 if (abs(x) > (abs(z) + abs(q))) {
853 H[i+1][
n-1] = (-ra - w * H[i][
n-1] + q * H[i][
n]) / x;
854 H[i+1][
n] = (-sa - w * H[i][
n] - q * H[i][
n-1]) / x;
856 cdiv(-r-y*H[i][
n-1],-s-y*H[i][
n],z,q);
864 t = std::max(abs(H[i][
n-1]),abs(H[i][
n]));
865 if ((eps * t) * t > 1) {
866 for (
int j = i; j <=
n; j++) {
867 H[j][
n-1] = H[j][
n-1] / t;
868 H[j][
n] = H[j][
n] / t;
878 for (
int i = 0; i < nn; i++) {
879 if (i < low || i > high) {
880 for (
int j = i; j < nn; j++) {
888 for (
int j = nn-1; j >= low; j--) {
889 for (
int i = low; i <= high; i++) {
891 for (
int k = low; k <= std::min(j,high); k++) {
892 z = z +
V[i][k] * H[k][j];
913 for (
int j = 0; (j <
n) && issymmetric; j++) {
914 for (
int i = 0; (i <
n) && issymmetric; i++) {
915 issymmetric = (A[i][j] == A[j][i]);
920 for (
int i = 0; i <
n; i++) {
921 for (
int j = 0; j <
n; j++) {
936 for (
int j = 0; j <
n; j++) {
937 for (
int i = 0; i <
n; i++) {
1015 for (
int i = 0; i <
n; i++) {
1016 for (
int j = 0; j <
n; j++) {
1022 }
else if (
e[i] < 0) {