69 M[0] = i2hess[0]*cosA*cosA + i2hess[1]*sinA*sinA;
72 M[21] = i2hess[0]*sinA*sinA + i2hess[1]*cosA*cosA;
75 M[3] = (i2hess[0] - i2hess[1])*cosA*sinA;
98 mx[7] = sqrt(mx[7] - mx[1]*mx[1]);
99 mx[8] = (mx[8] - mx[1]*mx[2])/mx[7];
100 mx[9] = (mx[9] - mx[1]*mx[3])/mx[7];
101 mx[10] = (mx[10] - mx[1]*mx[4])/mx[7];
102 mx[11] = (mx[11] - mx[1]*mx[5])/mx[7];
104 mx[14] = sqrt(mx[14] - mx[2]*mx[2] - mx[8]*mx[8]);
105 mx[15] = (mx[15] - mx[2]*mx[3] - mx[8]*mx[9])/mx[14];
106 mx[16] = (mx[16] - mx[2]*mx[4] - mx[8]*mx[10])/mx[14];
107 mx[17] = (mx[17] - mx[2]*mx[5] - mx[8]*mx[11])/mx[14];
109 mx[21] = sqrt(mx[21] - mx[3]*mx[3] - mx[9]*mx[9] - mx[15]*mx[15]);
110 mx[22] = (mx[22] - mx[3]*mx[4] - mx[9]*mx[10] - mx[15]*mx[16])/mx[21];
111 mx[23] = (mx[23] - mx[3]*mx[5] - mx[9]*mx[11] - mx[15]*mx[17])/mx[21];
113 mx[28] = sqrt(mx[28] - mx[4]*mx[4] - mx[10]*mx[10] - mx[16]*mx[16] - mx[22]*mx[22]);
114 mx[29] = (mx[29] - mx[4]*mx[5] - mx[10]*mx[11] - mx[16]*mx[17] - mx[22]*mx[23])/mx[28];
116 mx[35] = sqrt(mx[35] - mx[5]*mx[5] - mx[11]*mx[11] - mx[17]*mx[17] - mx[23]*mx[23] - mx[29]*mx[29]);
164 ecLc[0] = -
MAT[0]/ecLp[0];
165 ecLc[3] = -
MAT[3]/ecLp[0];
167 ecLc[6] = (-
MAT[1] - ecLc[0] * ecLp[1]) / ecLp[7];
168 ecLc[7] = -
MAT[7] / ecLp[7];
169 ecLc[9] = ( - ecLc[3] * ecLp[1]) / ecLp[7];
171 ecLc[12] = (-
MAT[2] - ecLc[0] * ecLp[2] - ecLc[6] * ecLp[8]) / ecLp[14];
172 ecLc[13] = (-
MAT[8] - ecLc[7] * ecLp[8]) / ecLp[14];
173 ecLc[14] = -
MAT[14] / ecLp[14];
174 ecLc[15] = ( - ecLc[3] * ecLp[2] - ecLc[9] * ecLp[8]) / ecLp[14];
176 ecLc[18] = (-
MAT[3] - ecLc[0]*ecLp[3] - ecLc[6]*ecLp[9] - ecLc[12]*ecLp[15]) / ecLp[21];
177 ecLc[19] = ( - ecLc[7]*ecLp[9] - ecLc[13]*ecLp[15])/ecLp[21];
178 ecLc[20] = ( - ecLc[14]*ecLp[15]) / ecLp[21];
179 ecLc[21] = (-
MAT[21] - ecLc[3]*ecLp[3] - ecLc[9]*ecLp[9] - ecLc[15]*ecLp[15]) / ecLp[21];
181 ecLc[24] = ( - ecLc[0]*ecLp[4] - ecLc[6]*ecLp[10] - ecLc[12]*ecLp[16] - ecLc[18]*ecLp[22]) / ecLp[28];
182 ecLc[25] = ( - ecLc[7]*ecLp[10] - ecLc[13]*ecLp[16] - ecLc[19]*ecLp[22]) / ecLp[28];
183 ecLc[26] = ( - ecLc[14]*ecLp[16] - ecLc[20]*ecLp[22]) / ecLp[28];
184 ecLc[27] = (-
MAT[22] - ecLc[3]*ecLp[4] - ecLc[9]*ecLp[10] - ecLc[15]*ecLp[16] - ecLc[21]*ecLp[22]) / ecLp[28];
185 ecLc[28] = -
MAT[28] / ecLp[28];
187 ecLc[30] = ( - ecLc[0]*ecLp[5] - ecLc[6]*ecLp[11] - ecLc[12]*ecLp[17] - ecLc[18]*ecLp[23] - ecLc[24]*ecLp[29]) / ecLp[35];
188 ecLc[31] = ( - ecLc[7]*ecLp[11] - ecLc[13]*ecLp[17] - ecLc[19]*ecLp[23] - ecLc[25]*ecLp[29]) / ecLp[35];
189 ecLc[32] = ( - ecLc[14]*ecLp[17] - ecLc[20]*ecLp[23] - ecLc[26]*ecLp[29]) / ecLp[35];
190 ecLc[33] = (-
MAT[23] - ecLc[3]*ecLp[5] - ecLc[9]*ecLp[11] - ecLc[15]*ecLp[17] - ecLc[21]*ecLp[23] - ecLc[27]*ecLp[29]) / ecLp[35];
191 ecLc[34] = (-
MAT[29] - ecLc[28]*ecLp[29])/ ecLp[35];
192 ecLc[35] = -
MAT[35] / ecLp[35];
212 ecLc[0] = i2P * B[0]*B[0] +
M[0];
213 ecLc[28] = ecLc[7] = i2P * B[1]*B[1] +
M[7];
214 ecLc[35] = ecLc[14] = i2P * B[2]*B[2] +
M[14];
215 ecLc[21] = i2P * B[0]*B[0] +
M[21];
218 ecLc[22] = ecLc[1] = i2P * B[0]*B[1];
219 ecLc[23] = ecLc[2] = i2P * B[0]*B[2];
220 ecLc[29] = ecLc[8] = i2P * B[1]*B[2];
224 ecLc[4] = ecLc[5] = ecLc[9] = ecLc[10] = ecLc[11] =
225 ecLc[15] = ecLc[16] = ecLc[17] = 0;
248 const double tmpvar = A3*
MAT[1] + A6*
MAT[2] + i2P * B[0]*B[0];
250 result[0] = tmpvar +
M[0] +
MAT[0];
251 result[22] = result[1] = i2P * B[0]*B[1] +
MAT[1] + A3*
MAT[2];
252 result[23] = result[2] = i2P * B[0]*B[2] +
MAT[2];
253 result[3] =
M[3] +
MAT[3];
255 result[28] = result[7] = i2P * B[1]*B[1] +
M[7] +
MAT[7] + A3*
MAT[8];
256 result[29] = result[8] = i2P * B[1]*B[2] +
MAT[8];
258 result[35] = result[14] = i2P * B[2]*B[2] +
M[14] +
MAT[14];
260 result[21] = tmpvar +
M[21] +
MAT[21];
286 ecLc[0] += - p[0] *p[0] - p[6] *p[6] - p[12]*p[12] - p[18]*p[18] - p[24]*p[24] - p[30]*p[30];
287 ecLc[1] += - p[6] *p[7] - p[12]*p[13] - p[18]*p[19] - p[24]*p[25] - p[30]*p[31];
288 ecLc[2] += - p[12]*p[14] - p[18]*p[20] - p[24]*p[26] - p[30]*p[32];
289 ecLc[3] += - p[0] *p[3] - p[6] *p[9] - p[12]*p[15] - p[18]*p[21] - p[24]*p[27] - p[30]*p[33];
290 ecLc[4] = - p[24]*p[28] - p[30]*p[34];
291 ecLc[5] = - p[30]*p[35];
293 ecLc[7] += - p[7] *p[7] - p[13]*p[13] - p[19]*p[19] - p[25]*p[25] - p[31]*p[31];
294 ecLc[8] += - p[13]*p[14] - p[19]*p[20] - p[25]*p[26] - p[31]*p[32];
295 ecLc[9] = - p[7] *p[9] - p[13]*p[15] - p[19]*p[21] - p[25]*p[27] - p[31]*p[33];
296 ecLc[10] = - p[25]*p[28] - p[31]*p[34];
297 ecLc[11] = - p[31]*p[35];
299 ecLc[14] += - p[14]*p[14] - p[20]*p[20] - p[26]*p[26] - p[32]*p[32];
300 ecLc[15] = - p[14]*p[15] - p[20]*p[21] - p[26]*p[27] - p[32]*p[33];
301 ecLc[16] = - p[26]*p[28] - p[32]*p[34];
302 ecLc[17] = - p[32]*p[35];
304 ecLc[21] += - p[3] *p[3] - p[9] *p[9] - p[15]*p[15] - p[21]*p[21] - p[27]*p[27] - p[33]*p[33];
305 ecLc[22] += - p[27]*p[28] - p[33]*p[34];
306 ecLc[23] += - p[33]*p[35];
308 ecLc[28] += - p[28]*p[28] - p[34]*p[34];
309 ecLc[29] += - p[34]*p[35];
311 ecLc[35] += - p[35]*p[35];
339 double *ecL_prev = &
ecL[0];
340 for (i = 1; i < ppar.
N; i++)
377 double *ecL_cur = &
ecL[0];
385 xc[1] = (xc[1] - xc[0]*ecL_cur[1]) / ecL_cur[7];
386 xc[2] = (xc[2] - xc[0]*ecL_cur[2] - xc[1]*ecL_cur[8]) / ecL_cur[14];
387 xc[3] = (xc[3] - xc[0]*ecL_cur[3] - xc[1]*ecL_cur[9] - xc[2]*ecL_cur[15]) / ecL_cur[21];
388 xc[4] = (xc[4] - xc[0]*ecL_cur[4] - xc[1]*ecL_cur[10] - xc[2]*ecL_cur[16] - xc[3]*ecL_cur[22]) / ecL_cur[28];
389 xc[5] = (xc[5] - xc[0]*ecL_cur[5] - xc[1]*ecL_cur[11] - xc[2]*ecL_cur[17] - xc[3]*ecL_cur[23] - xc[4]*ecL_cur[29]) / ecL_cur[35];
392 for (
int i = 1; i < N; i++)
411 xc[0] -= xp[0]*ecL_prev[0] + xp[1]*ecL_prev[6] + xp[2]*ecL_prev[12] + xp[3]*ecL_prev[18] + xp[4]*ecL_prev[24] + xp[5]*ecL_prev[30];
412 xc[1] -= xp[1]*ecL_prev[7] + xp[2]*ecL_prev[13] + xp[3]*ecL_prev[19] + xp[4]*ecL_prev[25] + xp[5]*ecL_prev[31];
413 xc[2] -= xp[2]*ecL_prev[14] + xp[3]*ecL_prev[20] + xp[4]*ecL_prev[26] + xp[5]*ecL_prev[32];
414 xc[3] -= xp[0]*ecL_prev[3] + xp[1]*ecL_prev[9] + xp[2]*ecL_prev[15] + xp[3]*ecL_prev[21] + xp[4]*ecL_prev[27] + xp[5]*ecL_prev[33];
415 xc[4] -= xp[4]*ecL_prev[28] + xp[5]*ecL_prev[34];
416 xc[5] -= xp[5]*ecL_prev[35];
420 xc[1] = (xc[1] - xc[0]*ecL_cur[1]) / ecL_cur[7];
421 xc[2] = (xc[2] - xc[0]*ecL_cur[2] - xc[1]*ecL_cur[8]) / ecL_cur[14];
422 xc[3] = (xc[3] - xc[0]*ecL_cur[3] - xc[1]*ecL_cur[9] - xc[2]*ecL_cur[15]) / ecL_cur[21];
423 xc[4] = (xc[4] - xc[0]*ecL_cur[4] - xc[1]*ecL_cur[10] - xc[2]*ecL_cur[16] - xc[3]*ecL_cur[22]) / ecL_cur[28];
424 xc[5] = (xc[5] - xc[0]*ecL_cur[5] - xc[1]*ecL_cur[11] - xc[2]*ecL_cur[17] - xc[3]*ecL_cur[23] - xc[4]*ecL_cur[29]) / ecL_cur[35];
448 xc[5] /= ecL_cur[35];
449 xc[4] = (xc[4] - xc[5]*ecL_cur[29]) / ecL_cur[28];
450 xc[3] = (xc[3] - xc[5]*ecL_cur[23] - xc[4]*ecL_cur[22]) / ecL_cur[21];
451 xc[2] = (xc[2] - xc[5]*ecL_cur[17] - xc[4]*ecL_cur[16] - xc[3]*ecL_cur[15]) / ecL_cur[14];
452 xc[1] = (xc[1] - xc[5]*ecL_cur[11] - xc[4]*ecL_cur[10] - xc[3]*ecL_cur[9] - xc[2]*ecL_cur[8]) / ecL_cur[7];
453 xc[0] = (xc[0] - xc[5]*ecL_cur[5] - xc[4]*ecL_cur[4] - xc[3]*ecL_cur[3] - xc[2]*ecL_cur[2] - xc[1]*ecL_cur[1]) / ecL_cur[0];
455 for (
int i = N-2; i >= 0 ; i--)
473 xc[0] -= xp[0]*ecL_prev[0] + xp[3]*ecL_prev[3];
474 xc[1] -= xp[0]*ecL_prev[6] + xp[1]*ecL_prev[7] + xp[3]*ecL_prev[9];
475 xc[2] -= xp[0]*ecL_prev[12] + xp[1]*ecL_prev[13] + xp[2]*ecL_prev[14] + xp[3]*ecL_prev[15];
476 xc[3] -= xp[0]*ecL_prev[18] + xp[1]*ecL_prev[19] + xp[2]*ecL_prev[20] + xp[3]*ecL_prev[21];
477 xc[4] -= xp[0]*ecL_prev[24] + xp[1]*ecL_prev[25] + xp[2]*ecL_prev[26] + xp[3]*ecL_prev[27] + xp[4]*ecL_prev[28];
478 xc[5] -= xp[0]*ecL_prev[30] + xp[1]*ecL_prev[31] + xp[2]*ecL_prev[32] + xp[3]*ecL_prev[33] + xp[4]*ecL_prev[34] + xp[5]*ecL_prev[35];
481 xc[5] /= ecL_cur[35];
482 xc[4] = (xc[4] - xc[5]*ecL_cur[29]) / ecL_cur[28];
483 xc[3] = (xc[3] - xc[5]*ecL_cur[23] - xc[4]*ecL_cur[22]) / ecL_cur[21];
484 xc[2] = (xc[2] - xc[5]*ecL_cur[17] - xc[4]*ecL_cur[16] - xc[3]*ecL_cur[15]) / ecL_cur[14];
485 xc[1] = (xc[1] - xc[5]*ecL_cur[11] - xc[4]*ecL_cur[10] - xc[3]*ecL_cur[9] - xc[2]*ecL_cur[8]) / ecL_cur[7];
486 xc[0] = (xc[0] - xc[5]*ecL_cur[5] - xc[4]*ecL_cur[4] - xc[3]*ecL_cur[3] - xc[2]*ecL_cur[2] - xc[1]*ecL_cur[1]) / ecL_cur[0];
#define SMPC_NUM_STATE_VAR
Number of state variables.
A set of problem parameters.
void solve_backward(const int, double *)
Solve system ecL' * x = b using backward substitution.
double MAT[MATRIX_SIZE_6x6]
R * inv(Q) * R'.
double M[MATRIX_SIZE_6x6]
void form_M(const double, const double, const double *, const double *)
Forms M = R*inv(hess_phi)*R'.
#define MATRIX_SIZE_6x6
The number of elements in 6x6 matrix.
void chol_dec(double *)
Performs Cholesky decomposition of a matrix.
void form(const problem_parameters &, const double *)
Builds matrix L.
void solve_forward(const int, double *)
Solve system ecL * x = b using forward substitution.
void form_L_non_diag(const double *, double *)
Forms a 6x6 matrix L(k+1, k), which lies below the diagonal of L.
void form_MAT(const double, const double)
Forms matrix MAT = M * A'.
void form_L_diag(const double *, const double, double *)
Forms a 6x6 matrix L(0, 0) = chol (M + B * inv(2*P) * B).
void form_AMATMBiPB(const double, const double, const double *, const double, double *)
Forms matrix AMATMBiPB = A * M1 * A' + 0.5 * M2 + 0.5 * B * inv(P) * B.