Add mju_gather and mju_scatter, private engine functions.
PiperOrigin-RevId: 750245294 Change-Id: I3a14ccdd55a324d3fe206e388fb2a513772f5f5e
This commit is contained in:
committed by
Copybara-Service
parent
99490163df
commit
c2ac0d724e
@@ -1390,6 +1390,24 @@ void mju_n2d(double* res, const mjtNum* vec, int n) {
|
||||
|
||||
|
||||
|
||||
// gather
|
||||
void mju_gather(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
res[i] = vec[ind[i]];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// scatter
|
||||
void mju_scatter(mjtNum* restrict res, const mjtNum* restrict vec, const int* restrict ind, int n) {
|
||||
for (int i=0; i < n; i++) {
|
||||
res[ind[i]] = vec[i];
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
// insertion sort, increasing order
|
||||
void mju_insertionSort(mjtNum* list, int n) {
|
||||
for (int i=1; i < n; i++) {
|
||||
|
||||
Reference in New Issue
Block a user