Replace custom sort of sparse fixed tendons with mju_combineSparse.
PiperOrigin-RevId: 720219887 Change-Id: I0491b3cb8987c119c3864fc0b5c38ca303d8f7f0
This commit is contained in:
committed by
Copybara-Service
parent
d21f624264
commit
9605990648
@@ -665,7 +665,7 @@ void mj_tendon(const mjModel* m, mjData* d) {
|
||||
rowadr[i] = (i > 0 ? rowadr[i-1] + rownnz[i-1] : 0);
|
||||
}
|
||||
|
||||
// process joint tendon
|
||||
// process fixed tendon
|
||||
if (m->wrap_type[adr] == mjWRAP_JOINT) {
|
||||
// process all defined joints
|
||||
for (int j=0; j < tendon_num; j++) {
|
||||
@@ -677,9 +677,10 @@ void mj_tendon(const mjModel* m, mjData* d) {
|
||||
|
||||
// add to moment
|
||||
if (issparse) {
|
||||
J[rowadr[i] + rownnz[i]] = m->wrap_prm[adr+j];
|
||||
colind[rowadr[i] + rownnz[i]] = m->jnt_dofadr[k];
|
||||
rownnz[i]++;
|
||||
rownnz[i] = mju_combineSparse(J+rowadr[i], &m->wrap_prm[adr+j], 1, 1,
|
||||
rownnz[i], 1,
|
||||
colind+rowadr[i], &m->jnt_dofadr[k],
|
||||
sparse_buf, buf_ind);
|
||||
}
|
||||
|
||||
// add to moment: dense
|
||||
@@ -688,25 +689,6 @@ void mj_tendon(const mjModel* m, mjData* d) {
|
||||
}
|
||||
}
|
||||
|
||||
// sort on colind if sparse: custom insertion sort
|
||||
if (issparse) {
|
||||
int x, *list = colind+rowadr[i], nnz = rownnz[i];
|
||||
mjtNum y, *listy = J+rowadr[i];
|
||||
|
||||
for (int k=1; k < nnz; k++) {
|
||||
x = list[k];
|
||||
y = listy[k];
|
||||
int j = k-1;
|
||||
while (j >= 0 && list[j] > x) {
|
||||
list[j+1] = list[j];
|
||||
listy[j+1] = listy[j];
|
||||
j--;
|
||||
}
|
||||
list[j+1] = x;
|
||||
listy[j+1] = y;
|
||||
}
|
||||
}
|
||||
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user