From 1a0ee5f055a76ceb06e649ae2f8bcf660c8ff212 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?S=C3=A9bastien=20Villemot?= Date: Tue, 9 Feb 2021 16:01:01 +0100 Subject: [PATCH] Bytecode / sparse transpose: bug fix The Jc vector has n+1 elements, where n is the number of columns. Moreover, the size passed to memset() was wrong. --- mex/sources/bytecode/SparseMatrix.cc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/mex/sources/bytecode/SparseMatrix.cc b/mex/sources/bytecode/SparseMatrix.cc index bb4e2eaf4..ef790d8c5 100644 --- a/mex/sources/bytecode/SparseMatrix.cc +++ b/mex/sources/bytecode/SparseMatrix.cc @@ -1929,7 +1929,7 @@ dynSparseMatrix::Sparse_transpose(const mxArray *A_m) mwIndex *C_j = mxGetJc(C_m); double *C_d = mxGetPr(C_m); unsigned int nze_C = 0, nze_A = 0; - memset(C_j, 0, m_A); + fill_n(C_j, m_A+1, 0); map, double> B2; for (unsigned int i = 0; i < n_A; i++) while (nze_A < static_cast(A_j[i+1]))