Remove unnecessary argument in mju_mulSymVecSparse
PiperOrigin-RevId: 758688536 Change-Id: Ife1099b948215363ddaa6d0b0edcf3492edcddcc
This commit is contained in:
committed by
Copybara-Service
parent
71bdd915f7
commit
e1baa15776
@@ -1357,7 +1357,7 @@ static mjtNum CGsearch(mjCGContext* ctx, mjtNum tolerance, mjtNum ls_iterations)
|
|||||||
|
|
||||||
// compute Mv = M * v
|
// compute Mv = M * v
|
||||||
mju_mulSymVecSparse(ctx->Mv, ctx->M, ctx->search, nv,
|
mju_mulSymVecSparse(ctx->Mv, ctx->M, ctx->search, nv,
|
||||||
ctx->M_rownnz, ctx->M_rowadr, ctx->M_diagnum, ctx->M_colind);
|
ctx->M_rownnz, ctx->M_rowadr, ctx->M_colind);
|
||||||
|
|
||||||
// compute Jv = J * search (dense or sparse)
|
// compute Jv = J * search (dense or sparse)
|
||||||
if (!ctx->is_sparse) {
|
if (!ctx->is_sparse) {
|
||||||
@@ -1887,7 +1887,7 @@ static void mj_solCGNewton(const mjModel* m, mjData* d, int island, int maxiter,
|
|||||||
|
|
||||||
// compute Ma = M * qacc
|
// compute Ma = M * qacc
|
||||||
mju_mulSymVecSparse(ctx.Ma, ctx.M, ctx.qacc, nv,
|
mju_mulSymVecSparse(ctx.Ma, ctx.M, ctx.qacc, nv,
|
||||||
ctx.M_rownnz, ctx.M_rowadr, ctx.M_diagnum, ctx.M_colind);
|
ctx.M_rownnz, ctx.M_rowadr, ctx.M_colind);
|
||||||
|
|
||||||
|
|
||||||
// compute Jaref = J * qacc - aref (dense or sparse)
|
// compute Jaref = J * qacc - aref (dense or sparse)
|
||||||
|
|||||||
@@ -227,7 +227,7 @@ void mju_addToSymSparse(mjtNum* res, const mjtNum* mat, int n,
|
|||||||
void mju_mulSymVecSparse(mjtNum* restrict res, const mjtNum* restrict mat,
|
void mju_mulSymVecSparse(mjtNum* restrict res, const mjtNum* restrict mat,
|
||||||
const mjtNum* restrict vec, int n,
|
const mjtNum* restrict vec, int n,
|
||||||
const int* restrict rownnz, const int* restrict rowadr,
|
const int* restrict rownnz, const int* restrict rowadr,
|
||||||
const int* restrict diagnum, const int* restrict colind) {
|
const int* restrict colind) {
|
||||||
// clear res
|
// clear res
|
||||||
mju_zero(res, n);
|
mju_zero(res, n);
|
||||||
|
|
||||||
@@ -240,13 +240,6 @@ void mju_mulSymVecSparse(mjtNum* restrict res, const mjtNum* restrict mat,
|
|||||||
// diagonal
|
// diagonal
|
||||||
res[i] = row[diag] * vec[i];
|
res[i] = row[diag] * vec[i];
|
||||||
|
|
||||||
// TODO: consider using SIMD if diagnum[i] >= 4
|
|
||||||
|
|
||||||
// shortcut for diagonal row/column
|
|
||||||
if (diagnum[i]) {
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// off-diagonals
|
// off-diagonals
|
||||||
const int* ind = colind + adr;
|
const int* ind = colind + adr;
|
||||||
for (int k=diag-1; k >= 0; k--) {
|
for (int k=diag-1; k >= 0; k--) {
|
||||||
|
|||||||
@@ -64,8 +64,7 @@ MJAPI void mju_addToSymSparse(mjtNum* res, const mjtNum* mat, int n,
|
|||||||
// multiply symmetric matrix (only lower triangle represented) by vector:
|
// multiply symmetric matrix (only lower triangle represented) by vector:
|
||||||
// res = (mat + strict_upper(mat')) * vec
|
// res = (mat + strict_upper(mat')) * vec
|
||||||
MJAPI void mju_mulSymVecSparse(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int n,
|
MJAPI void mju_mulSymVecSparse(mjtNum* res, const mjtNum* mat, const mjtNum* vec, int n,
|
||||||
const int* rownnz, const int* rowadr, const int* diagnum,
|
const int* rownnz, const int* rowadr, const int* colind);
|
||||||
const int* colind);
|
|
||||||
|
|
||||||
// compress sparse matrix, remove elements with abs(value) <= minval, return total non-zeros
|
// compress sparse matrix, remove elements with abs(value) <= minval, return total non-zeros
|
||||||
MJAPI int mju_compressSparse(mjtNum* mat, int nr, int nc,
|
MJAPI int mju_compressSparse(mjtNum* mat, int nr, int nc,
|
||||||
|
|||||||
@@ -1075,7 +1075,7 @@ TEST_F(EngineUtilSparseTest, MjuMulSymVecSparse) {
|
|||||||
constexpr int nnz = 9;
|
constexpr int nnz = 9;
|
||||||
|
|
||||||
mjtNum mat[n*n] = {1, 0, 0, 0,
|
mjtNum mat[n*n] = {1, 0, 0, 0,
|
||||||
-1, 2, 0, 0, // spurious (ignored) -1 at (1, 0)
|
0, 2, 0, 0,
|
||||||
3, 0, 4, 0,
|
3, 0, 4, 0,
|
||||||
5, 6, 7, 8};
|
5, 6, 7, 8};
|
||||||
|
|
||||||
@@ -1090,12 +1090,11 @@ TEST_F(EngineUtilSparseTest, MjuMulSymVecSparse) {
|
|||||||
int rowadr[n];
|
int rowadr[n];
|
||||||
int colind[nnz];
|
int colind[nnz];
|
||||||
mju_dense2sparse(mat_sparse, mat, n, n, rownnz, rowadr, colind, nnz);
|
mju_dense2sparse(mat_sparse, mat, n, n, rownnz, rowadr, colind, nnz);
|
||||||
int diagnum[n] = {0, 1, 0, 0};
|
|
||||||
|
|
||||||
// multiply: res = (mat + strict_upper(mat')) * vec
|
// multiply: res = (mat + strict_upper(mat')) * vec
|
||||||
mjtNum vec[n] = {4, 3, 2, 1};
|
mjtNum vec[n] = {4, 3, 2, 1};
|
||||||
mjtNum res[n];
|
mjtNum res[n];
|
||||||
mju_mulSymVecSparse(res, mat_sparse, vec, n, rownnz, rowadr, diagnum, colind);
|
mju_mulSymVecSparse(res, mat_sparse, vec, n, rownnz, rowadr, colind);
|
||||||
|
|
||||||
// dense multiply
|
// dense multiply
|
||||||
mjtNum res2[n];
|
mjtNum res2[n];
|
||||||
|
|||||||
Reference in New Issue
Block a user