57{
58#ifndef EVALS_ONLY
59 double norm;
60
61 double error;
62 double t, u;
63 int j;
64#endif
65
66
68
69#ifndef EVALS_ONLY
70
71
72
73 t = fabs(w[0]);
74 if ((u=fabs(w[1])) > t)
75 t = u;
76 if ((u=fabs(w[2])) > t)
77 t = u;
78 if (t < 1.0)
79 u = t;
80 else
82 error = 256.0 * DBL_EPSILON *
SQR(u);
83
84
85 Q[0][1] = A[0][1]*A[1][2] - A[0][2]*real(A[1][1]);
86 Q[1][1] = A[0][2]*conj(A[0][1]) - A[1][2]*real(A[0][0]);
88
89
90
91 Q[0][0] = Q[0][1] + A[0][2]*w[0];
92 Q[1][0] = Q[1][1] + A[1][2]*w[0];
93 Q[2][0] = (real(A[0][0]) - w[0]) * (real(A[1][1]) - w[0]) - Q[2][1];
95
96
97
98
99
100
101
102 if (norm <= error)
104 else
105 {
106 norm = sqrt(1.0 / norm);
107 for (j=0; j < 3; j++)
108 Q[j][0] = Q[j][0] * norm;
109 }
110
111
112
113 Q[0][1] = Q[0][1] + A[0][2]*w[1];
114 Q[1][1] = Q[1][1] + A[1][2]*w[1];
115 Q[2][1] = (real(A[0][0]) - w[1]) * (real(A[1][1]) - w[1]) - real(Q[2][1]);
117 if (norm <= error)
119 else
120 {
121 norm = sqrt(1.0 / norm);
122 for (j=0; j < 3; j++)
123 Q[j][1] = Q[j][1] * norm;
124 }
125
126
127
128 Q[0][2] = conj(Q[1][0]*Q[2][1] - Q[2][0]*Q[1][1]);
129 Q[1][2] = conj(Q[2][0]*Q[0][1] - Q[0][0]*Q[2][1]);
130 Q[2][2] = conj(Q[0][0]*Q[1][1] - Q[1][0]*Q[0][1]);
131#endif
132
133 return 0;
134}
int zheevc3(std::complex< double > A[3][3], double w[3])
int zheevq3(std::complex< double > A[3][3], std::complex< double > Q[3][3], double w[3])