mm_to_bcsr.h 752 B

12345678910111213141516171819202122232425262728293031323334353637
  1. #include <string.h>
  2. #include <stdint.h>
  3. #include <stdio.h>
  4. #include <stdlib.h>
  5. #include "mmio.h"
  6. /* convert a matrix stored in a file with the matrix market format into the
  7. * BCSR format */
  8. typedef struct tmp_block {
  9. /* we have a linked list of blocks */
  10. struct tmp_block *next;
  11. /* column i, row j*/
  12. unsigned i, j;
  13. float *val;
  14. } tmp_block_t;
  15. typedef struct {
  16. unsigned r,c;
  17. unsigned nnz_blocks;
  18. unsigned nrows_blocks;
  19. float *val;
  20. uint32_t *colind;
  21. uint32_t *rowptr;
  22. } bcsr_t;
  23. /* directly read input from a file */
  24. bcsr_t *mm_file_to_bcsr(char *filename, unsigned c, unsigned r);
  25. /* read the matrix as a set of valuated coordinates */
  26. bcsr_t *mm_to_bcsr(unsigned nz, unsigned *I, unsigned *J, float *val, unsigned c, unsigned r);