Separate mj_addM into dense and sparse functions.

PiperOrigin-RevId: 539066339
Change-Id: Ide3f9644fee46a5fb1a2e79a25be162b929e2421
This commit is contained in:
Kyle Bayes
2023-06-09 06:43:34 -07:00
committed by Copybara-Service
parent 466c9aca82
commit 81d74c56e1
4 changed files with 133 additions and 109 deletions
+2 -2
View File
@@ -1375,7 +1375,7 @@ static void HessianDirect(const mjModel* m, mjData* d, mjCGContext* ctx) {
d->efc_JT_colind, d->efc_JT_rowsuper, d);
// compute H = M + J'*D*J
mj_addM(m, d, ctx->H, ctx->rownnz, ctx->rowadr, ctx->colind);
mj_addMSparse(m, d, ctx->H, ctx->rownnz, ctx->rowadr, ctx->colind);
// factorize H, uncompressed layout
int rank = mju_cholFactorSparse(ctx->H, nv, mjMINVAL,
@@ -1404,7 +1404,7 @@ static void HessianDirect(const mjModel* m, mjData* d, mjCGContext* ctx) {
else {
// compute H = M + J'*D*J
mju_sqrMatTD(ctx->H, d->efc_J, D, nefc, nv);
mj_addM(m, d, ctx->H, NULL, NULL, NULL);
mj_addMDense(m, d, ctx->H);
// factorize H
mju_cholFactor(ctx->H, nv, mjMINVAL);