00001 /* Author: Andrew I. Schein -*- c++ -*- */ 00002 00003 #ifndef NPS_CSR_H 00004 #define NPS_CSR_H 00005 #include <stdint.h> 00006 00007 /* Compressed Sparse Row (CSR) matrix. 00008 This implementation uses 0-base indexing consistently throughout. 00009 */ 00010 00011 typedef struct { 00012 int64_t nRows; 00013 int64_t nCols; 00014 int64_t rAlloc; /* space for this many rows was allocated */ 00015 int64_t bufAlloc; /* space for this many total vals was allocated */ 00016 int64_t *r2St; /* row index -> start */ 00017 int64_t *r2Sz; /* row index -> number of els */ 00018 /* the two above are used to index the two below */ 00019 int64_t *cIx; /* column index buffer */ 00020 double *val; /* data buffer */ 00021 } nps_csr_t; 00022 00023 00024 /* allocate space for struct. Everything set to zero. 00025 nRows - the number of rows to allocate space for 00026 sizeBuff - the size of the allocation for the buffer 00027 */ 00028 extern nps_csr_t *nps_csr_alloc( int64_t nRows, int64_t sizeBuff); 00029 00030 /* realloc space for portions of struct. */ 00031 extern void nps_csr_realloc_rows(nps_csr_t *, int64_t); 00032 extern void nps_csr_realloc_vals (nps_csr_t *, int64_t); 00033 /* free struct */ 00034 extern void nps_csr_free(nps_csr_t *); 00035 00036 00037 #endif