00001 /* Author: Andrew Schein -*- c++ -*- */ 00002 00003 /* Compact representation of a collection of classifier instances containing sparse values. */ 00004 00005 #ifndef NPS_IMAT_CSR_H 00006 #define NPS_IMAT_CSR_H 00007 #include "imat_shared.h" 00008 #include "csr.h" 00009 00010 00011 #define T nps_imat_csr_t 00012 #define T_(x) nps_imat_csr_##x 00013 00014 /* Instance matrix wraps around a sparse matrix for providing functionality 00015 of a classifier instance. */ 00016 typedef struct { 00017 void *labDict; /* meta/label data for: labels */ 00018 void *featDict; /* features */ 00019 void *instDict; /* instances */ 00020 int64_t nCat; /* how many distinct categories are there? */ 00021 int64_t *labels; /* instance index -> label index */ 00022 f8_t *wghts; /* instance index -> weight */ 00023 nps_csr_t *m; /* sparse matrix holds predictors */ 00024 } nps_imat_csr_t; 00025 00026 extern T_(t) *T_(new)(int64_t init_labs, int64_t init_vals); 00027 extern void T_(del)(T_(t) *o); 00028 00029 /* fill with mutable dictionary both fills the _t struct and builds up the dictionary 00030 filename is given for error reporting */ 00031 int nps_imat_fill_mut(nps_imat_state *, nps_imat_csr_t **o, nps_error_t *err); 00032 /* fill, but don't alter the dictionary. */ 00033 int nps_imat_fill_frz(nps_imat_state *, nps_imat_csr_t **o, nps_error_t *err); 00034 00035 #ifndef NPS_IMAT_KEEP 00036 #include "imat_undef.h" 00037 #endif 00038 #endif