mju_transposeSparse: extract local integer, remove extra blank line.

PiperOrigin-RevId: 506243573
Change-Id: Ia573c9289ef1deb1cc7b5477d441752370caa470
This commit is contained in:
Yuval Tassa
2023-02-01 01:26:47 -08:00
committed by Copybara-Service
parent 7feecf6e94
commit a7888d473c
+4 -6
View File
@@ -550,15 +550,13 @@ void mju_transposeSparse(mjtNum* res, const mjtNum* mat, int nr, int nc,
// iterate through each non-zero entry of mat
for (int i = 0; i<nnz; i++) {
// iterate to get to the current row (skipping rows with all zeros)
while ((i-rowadr[r]) >= rownnz[r]) r++;
// row index becomes the column index
res[res_rowadr[colind[i]]] = mat[i];
// column index becomes the row index (increment the rowadr)
res_colind[res_rowadr[colind[i]]++] = r;
// swap rows with columns and increment res_rowadr
int c = res_rowadr[colind[i]]++;
res[c] = mat[i];
res_colind[c] = r;
}
// shift back row addresses