From e8c566bee1348006d54dfdad791c1723c7ccdf4d Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Thu, 15 May 2025 00:38:33 -0700 Subject: [PATCH] Remove use of `diagnum` in solver PiperOrigin-RevId: 759021147 Change-Id: I9e5c85b6542380780fc487781398f406ddaad51b --- doc/includes/references.h | 1 - include/mujoco/mjdata.h | 1 - include/mujoco/mjxmacro.h | 1 - python/mujoco/introspect/structs.py | 8 -------- src/engine/engine_island.c | 19 ------------------- src/engine/engine_solver.c | 3 --- unity/Runtime/Bindings/MjBindings.cs | 1 - 7 files changed, 34 deletions(-) diff --git a/doc/includes/references.h b/doc/includes/references.h index 9726123d..59320911 100644 --- a/doc/includes/references.h +++ b/doc/includes/references.h @@ -392,7 +392,6 @@ struct mjData_ { mjtNum* iacc_smooth; // unconstrained acceleration (nidof x 1) int* iM_rownnz; // inertia: non-zeros in each row (nidof x 1) int* iM_rowadr; // inertia: address of each row in iM_colind (nidof x 1) - int* iM_diagnum; // inertia: num of consecutive diagonal elements (nidof x 1) int* iM_colind; // inertia: column indices of non-zeros (nC x 1) mjtNum* iM; // total inertia (sparse) (nC x 1) mjtNum* iLD; // L'*D*L factorization of M (sparse) (nC x 1) diff --git a/include/mujoco/mjdata.h b/include/mujoco/mjdata.h index ac780c82..c05db9ab 100644 --- a/include/mujoco/mjdata.h +++ b/include/mujoco/mjdata.h @@ -420,7 +420,6 @@ struct mjData_ { mjtNum* iacc_smooth; // unconstrained acceleration (nidof x 1) int* iM_rownnz; // inertia: non-zeros in each row (nidof x 1) int* iM_rowadr; // inertia: address of each row in iM_colind (nidof x 1) - int* iM_diagnum; // inertia: num of consecutive diagonal elements (nidof x 1) int* iM_colind; // inertia: column indices of non-zeros (nC x 1) mjtNum* iM; // total inertia (sparse) (nC x 1) mjtNum* iLD; // L'*D*L factorization of M (sparse) (nC x 1) diff --git a/include/mujoco/mjxmacro.h b/include/mujoco/mjxmacro.h index b381d5d2..ecd40310 100644 --- a/include/mujoco/mjxmacro.h +++ b/include/mujoco/mjxmacro.h @@ -758,7 +758,6 @@ X( mjtNum, iacc_smooth, MJ_D(nidof), 1 ) \ X( int, iM_rownnz, MJ_D(nidof), 1 ) \ X( int, iM_rowadr, MJ_D(nidof), 1 ) \ - X( int, iM_diagnum, MJ_D(nidof), 1 ) \ X( int, iM_colind, MJ_M(nC), 1 ) \ X( mjtNum, iM, MJ_M(nC), 1 ) \ X( mjtNum, iLD, MJ_M(nC), 1 ) \ diff --git a/python/mujoco/introspect/structs.py b/python/mujoco/introspect/structs.py index d9f04366..4aac02a9 100644 --- a/python/mujoco/introspect/structs.py +++ b/python/mujoco/introspect/structs.py @@ -6024,14 +6024,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([ doc='inertia: address of each row in iM_colind', array_extent=('nidof',), ), - StructFieldDecl( - name='iM_diagnum', - type=PointerType( - inner_type=ValueType(name='int'), - ), - doc='inertia: num of consecutive diagonal elements', - array_extent=('nidof',), - ), StructFieldDecl( name='iM_colind', type=PointerType( diff --git a/src/engine/engine_island.c b/src/engine/engine_island.c index d38943d4..05364373 100644 --- a/src/engine/engine_island.c +++ b/src/engine/engine_island.c @@ -544,25 +544,6 @@ void mj_island(const mjModel* m, mjData* d) { d->iM, d->M); mju_gather(d->iLDiagInv, d->qLDiagInv, d->map_idof2dof, nidof); - // compute iM_diagnum (dof_simplenum per island) - int count = 0; - int dof_next = d->map_idof2dof[nidof-1]; - for (int i=nidof-1; i >= 0; i--) { - // check if island boundary was crossed - int dof = d->map_idof2dof[i]; - int island_boundary = (d->dof_island[dof] != d->dof_island[dof_next]); - dof_next = dof; - - // accumulate and set simple dof (diagonal row) counter - if (m->dof_simplenum[dof] && !island_boundary) { - count++; // increment counter - } else { - count = 0; // reset - } - d->iM_diagnum[i] = count; - } - - // ------------------------------------- constraints --------------------------------------------- diff --git a/src/engine/engine_solver.c b/src/engine/engine_solver.c index 7568b0f6..37b83024 100644 --- a/src/engine/engine_solver.c +++ b/src/engine/engine_solver.c @@ -786,7 +786,6 @@ struct _mjCGContext { // inertia const int* M_rownnz; const int* M_rowadr; - const int* M_diagnum; const int* M_colind; const mjtNum* M; const mjtNum* qLD; @@ -888,7 +887,6 @@ static void CGpointers(const mjModel* m, const mjData* d, mjCGContext* ctx, int // inertia ctx->M_rownnz = d->M_rownnz; ctx->M_rowadr = d->M_rowadr; - ctx->M_diagnum = m->dof_simplenum; ctx->M_colind = d->M_colind; ctx->M = d->M; ctx->qLD = d->qLD; @@ -937,7 +935,6 @@ static void CGpointers(const mjModel* m, const mjData* d, mjCGContext* ctx, int // inertia ctx->M_rownnz = d->iM_rownnz + idofadr; ctx->M_rowadr = d->iM_rowadr + idofadr; - ctx->M_diagnum = d->iM_diagnum + idofadr; ctx->M_colind = d->iM_colind; ctx->M = d->iM; ctx->qLD = d->iLD; diff --git a/unity/Runtime/Bindings/MjBindings.cs b/unity/Runtime/Bindings/MjBindings.cs index 4f0d209b..d0dd61aa 100644 --- a/unity/Runtime/Bindings/MjBindings.cs +++ b/unity/Runtime/Bindings/MjBindings.cs @@ -5004,7 +5004,6 @@ public unsafe struct mjData_ { public double* iacc_smooth; public int* iM_rownnz; public int* iM_rowadr; - public int* iM_diagnum; public int* iM_colind; public double* iM; public double* iLD;