contrib/sparse/sparse-matrix.c
/**
 * sparse_matrix_reserve_range:
 *
 * Pre-allocate a range of non-zero entries along a row.
 */
Pre-allocate a range of non-zero entries along a row.
Pre - allocate a range of non - zero entries along a row .
void
sparse_matrix_reserve_range (SparseMatrix *matrix, size_t i, size_t *colind, size_t n)
{
    if (matrix->storage == SPARSE_MATRIX_STORAGE_DENSE)
        return;
    assert ((i == matrix->shape[0] - 1) || matrix->s.csr.rowptr[i+1] == 0);
    assert (matrix->s.csr.rowptr[i] + n <= matrix->s.csr.nnz);
    matrix->s.csr.rowptr[i + 1] = matrix->s.csr.rowptr[i] + n;
    memcpy (matrix->s.csr.colind + matrix->s.csr.rowptr[i], colind, n * sizeof (size_t));
}
void sparse_matrix_reserve_range ( SparseMatrix * matrix , size_t i , size_t * colind , size_t n ) { if ( matrix -> storage == SPARSE_MATRIX_STORAGE_DENSE ) return ; assert ( ( i == matrix -> shape [ 0 ] - 1 ) || matrix -> s . csr . rowptr [ i + 1 ] == 0 ) ; assert ( matrix -> s . csr . rowptr [ i ] + n <= matrix -> s . csr . nnz ) ; matrix -> s . csr . rowptr [ i + 1 ] = matrix -> s . csr . rowptr [ i ] + n ; memcpy ( matrix -> s . csr . colind + matrix -> s . csr . rowptr [ i ] , colind , n * sizeof ( size_t ) ) ; }
sparse_matrix_reserve_range:
 Pre-allocate a range of non-zero entries along a row.
sparse_matrix_reserve_range : Pre - allocate a range of non - zero entries along a row .