-
Notifications
You must be signed in to change notification settings - Fork 5
Expand file tree
/
Copy pathbsp2mtx.c
More file actions
36 lines (28 loc) · 812 Bytes
/
bsp2mtx.c
File metadata and controls
36 lines (28 loc) · 812 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
/*
* SPDX-FileCopyrightText: 2024 Binsparse Developers
*
* SPDX-License-Identifier: BSD-3-Clause
*/
#include <binsparse/binsparse.h>
#include <stdio.h>
int main(int argc, char** argv) {
if (argc < 3) {
printf(
"usage: ./bsp2mtx [inputfile_name.mtx] [outputfile_name.bsp.hdf5]\n");
return 1;
}
char* input_fname = argv[1];
char* output_fname = argv[2];
printf(" === Reading file... ===\n");
bsp_matrix_t matrix;
BSP_CHECK(bsp_read_matrix(&matrix, input_fname, NULL));
printf(" === Done reading. ===\n");
if (matrix.format != BSP_COO) {
matrix = bsp_convert_matrix(matrix, BSP_COO);
}
printf(" === Writing to %s... ===\n", output_fname);
bsp_mmwrite(output_fname, matrix);
printf(" === Done writing. ===\n");
bsp_destroy_matrix_t(&matrix);
return 0;
}