1
/* chouse.c CCMATH mathematics library source code.
3
* Copyright (C) 2000 Daniel A. Atkinson All rights reserved.
4
* This code may be redistributed under the terms of the GNU library
5
* public license (LGPL). ( See the lgpl.license file for details.)
6
* ------------------------------------------------------------------------
10
void chouse(Cpx * a, double *d, double *dp, int n)
20
q0 = (Cpx *) calloc(2 * n, sizeof(Cpx));
21
for (i = 0, p = q0 + n, pc = a; i < n; ++i, pc += n + 1)
23
for (j = 0, pc = a; j < n - 2; ++j, pc += n + 1) {
25
for (i = 1, sc = 0.; i <= m; ++i)
26
sc += pc[i].re * pc[i].re + pc[i].im * pc[i].im;
30
y = sc + (x = sqrt(p->re * p->re + p->im * p->im));
39
x = 1. / sqrt(2. * sc * y);
41
for (i = 0, qw = pc + 1; i < m; ++i) {
42
q0[i].re = q0[i].im = 0.;
49
qw[0].im = -y * cc.im;
52
for (i = 0, e = j + 2, p = pc + n + 1, y = 0.; i < m;
54
q0[i].re += (u.re = qw[i].re) * p->re - (u.im =
56
q0[i].im += u.re * p->im + u.im * p->re;
58
for (k = i + 1; k < m; ++k, ++p) {
59
q0[i].re += qw[k].re * p->re - qw[k].im * p->im;
60
q0[i].im += qw[k].im * p->re + qw[k].re * p->im;
61
q0[k].re += u.re * p->re + u.im * p->im;
62
q0[k].im += u.im * p->re - u.re * p->im;
64
y += u.re * q0[i].re + u.im * q0[i].im;
66
for (i = 0; i < m; ++i) {
67
q0[i].re -= y * qw[i].re;
69
q0[i].im -= y * qw[i].im;
72
for (i = 0, e = j + 2, p = pc + n + 1; i < m; ++i, p += e++) {
73
for (k = i; k < m; ++k, ++p) {
74
p->re -= qw[i].re * q0[k].re + qw[i].im * q0[k].im
75
+ q0[i].re * qw[k].re + q0[i].im * qw[k].im;
76
p->im -= qw[i].im * q0[k].re - qw[i].re * q0[k].im
77
+ q0[i].im * qw[k].re - q0[i].re * qw[k].im;
85
d[j + 1] = (pc + n + 1)->re;
87
dp[j] = sqrt(u.re * u.re + u.im * u.im);
88
for (j = 0, pc = a, qw = q0 + n; j < n; ++j, pc += n + 1) {
90
for (i = 1, p = pc + n; i < n - j; ++i, p += n) {