MCPcopy Create free account
hub / github.com/RoboMaster/RoboRTS / Tql2

Function Tql2

roborts_localization/localization_math.cpp:165–286  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

163}
164
165inline void Tql2(Mat3d &matrix_v, Vec3d &vector_d, Vec3d &vector_e) {
166
167// This is derived from the Algol procedures tql2, by
168// Bowdler, Martin, Reinsch, and Wilkinson, Handbook for
169// Auto. Comp., Vol.ii-Linear Algebra, and the corresponding
170// Fortran subroutine in EISPACK.
171
172 int i, j, m, l, k;
173 double g, p, r, dl1, h, f, tst1, eps;
174 double c, c2, c3, el1, s, s2;
175
176 for (i = 1; i < 3; i++) {
177 vector_e[i - 1] = vector_e[i];
178 }
179 vector_e[3 - 1] = 0.0;
180
181 f = 0.0;
182 tst1 = 0.0;
183 eps = pow(2.0, -52.0);
184 for (l = 0; l < 3; l++) {
185
186 // Find small subdiagonal element
187
188 tst1 = std::max(tst1, fabs(vector_d[l]) + fabs(vector_e[l]));
189 m = l;
190 while (m < 3) {
191 if (fabs(vector_e[m]) <= eps * tst1) {
192 break;
193 }
194 m++;
195 }
196
197 // If m == l, d[l] is an eigenvalue,
198 // otherwise, iterate.
199
200 if (m > l) {
201 int iter = 0;
202 do {
203 iter = iter + 1; // (Could check iteration count here.)
204
205 // Compute implicit shift
206
207 g = vector_d[l];
208 p = (vector_d[l + 1] - g) / (2.0 * vector_e[l]);
209 r = std::sqrt(p * p + 1.0 * 1.0);
210// r = hypot2(p,1.0);
211 if (p < 0) {
212 r = -r;
213 }
214 vector_d[l] = vector_e[l] / (p + r);
215 vector_d[l + 1] = vector_e[l] * (p + r);
216 dl1 = vector_d[l + 1];
217 h = g - vector_d[l];
218 for (i = l + 2; i < 3; i++) {
219 vector_d[i] -= h;
220 }
221 f = f + h;
222

Callers 1

EigenDecompositionFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected