14 int i, j, k, m, lc, *le;
16 Cpx *
ps, *p, *q, *pa, *pd;
20 double s,
t, tq = 0., zr = 1.e-15;
22 le = (
int *)calloc(n,
sizeof(
int));
23 q0 = (
Cpx *)calloc(n,
sizeof(
Cpx));
25 for (j = 0; j < n; ++j, ++pa, pd += n + 1) {
27 for (i = 0, p = pa, q = q0; i < n; ++i, p += n)
29 for (i = 1; i < n; ++i) {
32 for (k = 0, p = pa + i * n - j, q = q0; k < lc; ++k, ++q, ++p) {
33 z.
re += p->re * q->re - p->im * q->im;
34 z.
im += p->im * q->re + p->re * q->im;
39 for (i = 0, p = pa, q = q0; i < n; ++i, p += n)
42 s = fabs(pd->
re) + fabs(pd->
im);
44 for (k = j + 1,
ps = pd; k < n; ++k) {
46 if ((
t = fabs(
ps->re) + fabs(
ps->im)) > s) {
61 for (k = 0; k < n; ++k, ++p, ++q) {
70 for (k = j + 1,
ps = pd + n; k < n; ++k,
ps += n) {
77 for (j = 1, pd =
ps = a; j < n; ++j) {
78 for (k = 0, pd += n + 1, q = ++
ps; k < j; ++k, q += n) {
79 z.
re = q->re * pd->
re - q->im * pd->
im;
80 z.
im = q->im * pd->
re + q->re * pd->
im;
84 for (j = 1, pa = a; j < n; ++j) {
86 for (i = 0, q = q0, p = pa; i < j; ++i, p += n)
88 for (k = 0; k < j; ++k) {
90 for (i = k, p = pa + k * n + k - j, q = q0 + k; i < j; ++i) {
91 h.
re -= p->re * q->
re - p->im * q->
im;
92 h.
im -= p->im * q->
re + p->re * q->
im;
98 for (i = 0, q = q0, p = pa; i < j; ++i, p += n)
101 for (j = n - 2, pd = pa = a + n * n - 1; j >= 0; --j) {
104 for (i = 0, m = n - j - 1, q = q0, p = pd + n; i < m; ++i, p += n)
106 for (k = n - 1,
ps = pa; k > j; --k,
ps -= n) {
109 for (i = j + 1, p =
ps + 1, q = q0; i < k; ++i, ++p, ++q) {
110 z.
re -= p->re * q->
re - p->im * q->
im;
111 z.
im -= p->im * q->
re + p->re * q->
im;
115 for (i = 0, m = n - j - 1, q = q0, p = pd + n; i < m; ++i, p += n)
118 for (k = 0, pa = a; k < n - 1; ++k, ++pa) {
119 for (i = 0, q = q0, p = pa; i < n; ++i, p += n)
121 for (j = 0,
ps = a; j < n; ++j,
ps += n) {
132 for (; i < n; ++i, ++p) {
133 h.
re += p->re * q0[i].
re - p->im * q0[i].
im;
134 h.
im += p->im * q0[i].
re + p->re * q0[i].
im;
138 for (i = 0, q = q0, p = pa; i < n; ++i, p += n)
141 for (j = n - 2, le--; j >= 0; --j) {
142 for (k = 0, p = a + j, q = a + *(--le); k < n; ++k, p += n, q += n) {