| 165 | |
| 166 | |
| 167 | int dInvertPDMatrix (const dReal *A, dReal *Ainv, int n) |
| 168 | { |
| 169 | int i,j,nskip; |
| 170 | dReal *L,*x; |
| 171 | dAASSERT (n > 0 && A && Ainv); |
| 172 | nskip = dPAD (n); |
| 173 | L = (dReal*) ALLOCA (nskip*n*sizeof(dReal)); |
| 174 | memcpy (L,A,nskip*n*sizeof(dReal)); |
| 175 | x = (dReal*) ALLOCA (n*sizeof(dReal)); |
| 176 | if (dFactorCholesky (L,n)==0) return 0; |
| 177 | dSetZero (Ainv,n*nskip); // make sure all padding elements set to 0 |
| 178 | for (i=0; i<n; i++) { |
| 179 | for (j=0; j<n; j++) x[j] = 0; |
| 180 | x[i] = 1; |
| 181 | dSolveCholesky (L,x,n); |
| 182 | for (j=0; j<n; j++) Ainv[j*nskip+i] = x[j]; |
| 183 | } |
| 184 | return 1; |
| 185 | } |
| 186 | |
| 187 | |
| 188 | int dIsPositiveDefinite (const dReal *A, int n) |
no test coverage detected