12 int i, j, k, m, lc, *le;
14 Cpx *
ps, *p, *q, *pa, *pd;
18 double s,
t, tq = 0., zr = 1.e-15;
20 le = (
int *)calloc(n,
sizeof(
int));
21 q0 = (
Cpx *) calloc(n,
sizeof(
Cpx));
23 for (j = 0; j < n; ++j, ++pa, pd += n + 1) {
25 for (i = 0, p = pa, q = q0; i < n; ++i, p += n)
27 for (i = 1; i < n; ++i) {
30 for (k = 0, p = pa + i * n - j, q = q0; k < lc; ++k, ++q, ++p) {
31 z.
re += p->re * q->re - p->im * q->im;
32 z.
im += p->im * q->re + p->re * q->im;
37 for (i = 0, p = pa, q = q0; i < n; ++i, p += n)
40 s = fabs(pd->re) + fabs(pd->im);
42 for (k = j + 1, ps = pd; k < n; ++k) {
44 if ((t = fabs(ps->
re) + fabs(ps->
im)) > s) {
59 for (k = 0; k < n; ++k, ++p, ++q) {
65 t = pd->
re * pd->re + pd->im * pd->im;
68 for (k = j + 1, ps = pd + n; k < n; ++k, ps += n) {
69 z.
re = ps->re * h.
re - ps->im * h.
im;
70 z.
im = ps->im * h.
re + ps->re * h.
im;
75 for (j = 1, pd = ps = a; j < n; ++j) {
76 for (k = 0, pd += n + 1, q = ++ps; k < j; ++k, q += n) {
77 z.
re = q->re * pd->re - q->im * pd->im;
78 z.
im = q->im * pd->re + q->re * pd->im;
82 for (j = 1, pa = a; j < n; ++j) {
84 for (i = 0, q = q0, p = pa; i < j; ++i, p += n)
86 for (k = 0; k < j; ++k) {
88 for (i = k, p = pa + k * n + k - j, q = q0 + k; i < j; ++i) {
89 h.
re -= p->re * q->
re - p->im * q->
im;
90 h.
im -= p->im * q->
re + p->re * q->
im;
96 for (i = 0, q = q0, p = pa; i < j; ++i, p += n)
99 for (j = n - 2, pd = pa = a + n * n - 1; j >= 0; --j) {
102 for (i = 0, m = n - j - 1, q = q0, p = pd + n; i < m; ++i, p += n)
104 for (k = n - 1, ps = pa; k > j; --k, ps -= n) {
107 for (i = j + 1, p = ps + 1, q = q0; i < k; ++i, ++p, ++q) {
108 z.
re -= p->re * q->
re - p->im * q->
im;
109 z.
im -= p->im * q->
re + p->re * q->
im;
113 for (i = 0, m = n - j - 1, q = q0, p = pd + n; i < m; ++i, p += n)
116 for (k = 0, pa = a; k < n - 1; ++k, ++pa) {
117 for (i = 0, q = q0, p = pa; i < n; ++i, p += n)
119 for (j = 0, ps = a; j < n; ++j, ps += n) {
130 for (; i < n; ++i, ++p) {
131 h.
re += p->re * q0[i].
re - p->im * q0[i].
im;
132 h.
im += p->im * q0[i].
re + p->re * q0[i].
im;
136 for (i = 0, q = q0, p = pa; i < n; ++i, p += n)
139 for (j = n - 2, le--; j >= 0; --j) {
140 for (k = 0, p = a + j, q = a + *(--le); k < n; ++k, p += n, q += n) {