23 void casadi_kkt(
const casadi_int* sp_kkt, T1* nz_kkt,
24 const casadi_int* sp_h,
const T1* nz_h,
25 const casadi_int* sp_a,
const T1* nz_a,
26 const T1* S,
const T1* D, T1* w, casadi_int* iw) {
28 casadi_int i, k, j, nx, nz;
29 const casadi_int *h_colind, *h_row, *a_colind, *a_row,
30 *kkt_colind, *kkt_row;
32 a_row = (a_colind = sp_a + 2) + (nx = sp_a[1]) + 1;
33 h_row = (h_colind = sp_h + 2) + nx + 1;
34 kkt_row = (kkt_colind = sp_kkt + 2) + (nz = sp_kkt[1]) + 1;
36 for (i = nx; i < nz; ++i) iw[i - nx] = kkt_colind[i];
40 for (i=0; i<nx; ++i) {
42 for (k=h_colind[i]; k<h_colind[i+1]; ++k) {
44 w[j] = nz_h[k] * S[i] * S[j];
47 for (k=a_colind[i]; k<a_colind[i+1]; ++k) {
49 w[j] = nz_a[k] * S[i] * S[j];
54 for (k=kkt_colind[i]; k<kkt_colind[i+1]; ++k) {
57 if (j >= nx) nz_kkt[iw[j - nx]++] = w[j];
60 for (k=h_colind[i]; k<h_colind[i+1]; ++k) w[h_row[k]] = 0;
61 for (k=a_colind[i]; k<a_colind[i+1]; ++k) w[a_row[k] + nx] = 0;
64 for (i=nx; i<nz; ++i) {
65 nz_kkt[iw[i - nx]++] = -D[i];