[fix] setting array->n after reading in both graph and sparse_matrix implementations
This commit is contained in:
@@ -284,8 +284,6 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
goto exit_sparse_matrix_allocated;
|
||||
}
|
||||
|
||||
sp->indptr = indptr;
|
||||
|
||||
for (int i = 0; i < len_indptr; i++) {
|
||||
if (!file_read_uint32(f, indptr->a + i)) {
|
||||
printf("indptr\n");
|
||||
@@ -293,6 +291,9 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
}
|
||||
}
|
||||
|
||||
indptr->n = (size_t)len_indptr;
|
||||
sp->indptr = indptr;
|
||||
|
||||
uint64_t len_indices;
|
||||
|
||||
if (!file_read_uint64(f, &len_indices)) {
|
||||
@@ -306,8 +307,6 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
goto exit_sparse_matrix_allocated;
|
||||
}
|
||||
|
||||
sp->indices = indices;
|
||||
|
||||
for (int i = 0; i < len_indices; i++) {
|
||||
if (!file_read_uint32(f, indices->a + i)) {
|
||||
printf("indices\n");
|
||||
@@ -315,6 +314,9 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
}
|
||||
}
|
||||
|
||||
indices->n = (size_t)len_indices;
|
||||
sp->indices = indices;
|
||||
|
||||
uint64_t len_data;
|
||||
|
||||
if (!file_read_uint64(f, &len_data)) {
|
||||
@@ -328,8 +330,6 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
goto exit_sparse_matrix_allocated;
|
||||
}
|
||||
|
||||
sp->data = data;
|
||||
|
||||
for (int i = 0; i < len_data; i++) {
|
||||
if (!file_read_double(f, data->a + i)) {
|
||||
printf("data\n");
|
||||
@@ -337,6 +337,9 @@ sparse_matrix_t *sparse_matrix_read(FILE *f) {
|
||||
}
|
||||
}
|
||||
|
||||
data->n = (size_t)len_data;
|
||||
sp->data = data;
|
||||
|
||||
return sp;
|
||||
|
||||
exit_sparse_matrix_allocated:
|
||||
|
||||
Reference in New Issue
Block a user