Add mju_clip, mju_fill, mju_eye and mju_symmetrize to python bindings.
- Also change signatures of `mju_fill` and `mju_symmetrize` to conform to standard. PiperOrigin-RevId: 485613824 Change-Id: I8dd618bac92ef40aa6c76380fa73302e81968687
This commit is contained in:
committed by
Copybara-Service
parent
7458a6e90f
commit
c83be2bc05
@@ -245,7 +245,7 @@ void mju_zero(mjtNum* res, int n) {
|
||||
|
||||
|
||||
// res = val
|
||||
void mju_fill(mjtNum* res, int n, mjtNum val) {
|
||||
void mju_fill(mjtNum* res, mjtNum val, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
res[i] = val;
|
||||
}
|
||||
@@ -740,12 +740,12 @@ void mju_transpose(mjtNum* res, const mjtNum* mat, int nr, int nc) {
|
||||
|
||||
|
||||
|
||||
// symmetrize square matrix M = (M + M')/2
|
||||
void mju_symmetrize(mjtNum* mat, int n) {
|
||||
// symmetrize square matrix res = (mat + mat')/2
|
||||
void mju_symmetrize(mjtNum* res, const mjtNum* mat, int n) {
|
||||
for (int i=0; i<n; i++) {
|
||||
res[i*(n+1)] = mat[i*(n+1)];
|
||||
for (int j=0; j<i; j++) {
|
||||
mjtNum tmp = 0.5 * (mat[i*n+j] + mat[j*n+i]);
|
||||
mat[i*n+j] = mat[j*n+i] = tmp;
|
||||
res[i*n+j] = res[j*n+i] = 0.5 * (mat[i*n+j] + mat[j*n+i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -131,7 +131,7 @@ MJAPI mjtNum mju_normalize4(mjtNum vec[4]);
|
||||
MJAPI void mju_zero(mjtNum* res, int n);
|
||||
|
||||
// res = val
|
||||
MJAPI void mju_fill(mjtNum* res, int n, mjtNum val);
|
||||
MJAPI void mju_fill(mjtNum* res, mjtNum val, int n);
|
||||
|
||||
// res = vec
|
||||
MJAPI void mju_copy(mjtNum* res, const mjtNum* vec, int n);
|
||||
@@ -192,8 +192,8 @@ MJAPI mjtNum mju_mulVecMatVec(const mjtNum* vec1, const mjtNum* mat, const mjtNu
|
||||
// transpose matrix
|
||||
MJAPI void mju_transpose(mjtNum* res, const mjtNum* mat, int nr, int nc);
|
||||
|
||||
// symmetrize square matrix M = (M + M')/2
|
||||
MJAPI void mju_symmetrize(mjtNum* mat, int n);
|
||||
// symmetrize square matrix res = (mat + mat')/2
|
||||
MJAPI void mju_symmetrize(mjtNum* res, const mjtNum* mat, int n);
|
||||
|
||||
// identity matrix
|
||||
MJAPI void mju_eye(mjtNum* mat, int n);
|
||||
|
||||
Reference in New Issue
Block a user