From 7e7cb177a40c2efe91d8cdd052983f6780b547b4 Mon Sep 17 00:00:00 2001 From: Yuval Tassa Date: Mon, 20 Feb 2023 09:22:42 -0800 Subject: [PATCH] Cosmetic changes. PiperOrigin-RevId: 511008317 Change-Id: Id8d7cd4f4e22e0658857d16b47d51053f1477bb9 --- src/engine/engine_util_sparse.c | 6 ++++++ test/benchmark/engine_util_sparse_benchmark_test.cc | 2 +- 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/engine_util_sparse.c b/src/engine/engine_util_sparse.c index 453702a3..067dc860 100644 --- a/src/engine/engine_util_sparse.c +++ b/src/engine/engine_util_sparse.c @@ -89,6 +89,7 @@ void mju_dotSparseX3(mjtNum* res0, mjtNum* res1, mjtNum* res2, } + // dot-product, both vectors are sparse mjtNum mju_dotSparse2(const mjtNum* vec1, const mjtNum* vec2, const int nnz1, const int* ind1, @@ -205,6 +206,7 @@ static int mju_compare(const int* vec1, const int* vec2, int n) { } + // combine two sparse vectors: dst = a*dst + b*src, return nnz of result int mju_combineSparse(mjtNum* dst, const mjtNum* src, int n, mjtNum a, mjtNum b, int dst_nnz, int src_nnz, int* dst_ind, const int* src_ind, @@ -329,6 +331,8 @@ void mju_compressSparse(mjtNum* mat, int nr, int nc, int* rownnz, int* rowadr, i } } + + // transpose sparse matrix void mju_transposeSparse(mjtNum* res, const mjtNum* mat, int nr, int nc, int* res_rownnz, int* res_rowadr, int* res_colind, @@ -405,6 +409,8 @@ void mju_superSparse(int nr, int* rowsuper, } } + + // compute sparse M'*diag*M (diag=NULL: compute M'*M), res has uncompressed layout void mju_sqrMatTDSparse(mjtNum* res, const mjtNum* mat, const mjtNum* matT, const mjtNum* diag, int nr, int nc, diff --git a/test/benchmark/engine_util_sparse_benchmark_test.cc b/test/benchmark/engine_util_sparse_benchmark_test.cc index cece3a81..e2787782 100644 --- a/test/benchmark/engine_util_sparse_benchmark_test.cc +++ b/test/benchmark/engine_util_sparse_benchmark_test.cc @@ -391,7 +391,7 @@ static void BM_transposeSparse(benchmark::State& state, TransposeFuncPtr func) { mjData* d = mj_makeData(m); // warm-up rollout to get a typical state - while (d-> time < 2) { + while (d->time < 2) { mj_step(m, d); }