Skip to content

Commit 0664e55

Browse files
committed
very minor changes
1 parent b84220f commit 0664e55

3 files changed

Lines changed: 5 additions & 9 deletions

File tree

src/utils/linalg_dense_sparse_matmuls.c

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,9 +35,7 @@ CSC_matrix *I_kron_A_alloc(const matrix *A, const CSC_matrix *J, int p)
3535
int n = A->n;
3636
int i, j, jj, block, block_start, block_end, block_jj_start, row_offset;
3737

38-
/* Ci grows via iVec_append, so this is only a capacity hint: seed from the
39-
source's true nnz, never the dense product J->n * m (which overflows int for
40-
large operands and over-allocates hugely for a sparse result). */
38+
/* capacity hint based on J->nnz and not on the dense product */
4139
int *Cp = (int *) sp_malloc((J->n + 1) * sizeof(int));
4240
iVec *Ci = iVec_new(J->nnz > 0 ? J->nnz : 1);
4341
Cp[0] = 0;

src/utils/linalg_sparse_matmuls.c

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -95,10 +95,8 @@ CSC_matrix *block_left_multiply_fill_sparsity(const CSR_matrix *A,
9595
int j, jj, block, block_start, block_end, block_jj_start, block_jj_end,
9696
row_offset;
9797

98-
/* allocate column pointers and an estimate of row indices. Ci grows via
99-
iVec_append, so this is only a capacity hint: seed from the source's true nnz,
100-
never the dense product J->n * m (which overflows int for large operands and
101-
over-allocates hugely for a sparse result). */
98+
/* Allocate column pointers and an estimate of row indices. Capacity hint
99+
based on J->nnz and not on the dense product */
102100
int *Cp = (int *) sp_malloc((J->n + 1) * sizeof(int));
103101
iVec *Ci = iVec_new(J->nnz > 0 ? J->nnz : 1);
104102
Cp[0] = 0;

src/utils/sparse_matrix.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -124,8 +124,8 @@ static void sparse_transpose_fill_values(const matrix *self, matrix *out)
124124
static matrix *sparse_index_alloc(matrix *self, const int *indices, int n_idxs)
125125
{
126126
CSR_matrix *Jx = ((sparse_matrix *) self)->csr;
127-
CSR_matrix *J =
128-
new_CSR_matrix(n_idxs, self->n, MIN(Jx->nnz, sat_mul_int(n_idxs, self->n)));
127+
int alloc_ub = sat_mul_int(n_idxs, self->n);
128+
CSR_matrix *J = new_CSR_matrix(n_idxs, self->n, MIN(Jx->nnz, alloc_ub));
129129

130130
J->p[0] = 0;
131131
for (int i = 0; i < n_idxs; i++)

0 commit comments

Comments
 (0)