#include // bool #include // fprintf() #include "util.h" #include "km.h" bool km_set_print( const km_set_t * const set, FILE * const fh ) { // print shape fprintf(fh, "%zu %zu\n", set->shape.num_floats, set->shape.num_ints); // print rows for (size_t i = 0; i < set->num_rows; i++) { if (set->shape.num_floats > 0) { const float * const vals = km_set_get_row(set, i); // print floats for (size_t j = 0; j < set->shape.num_floats; j++) { fprintf(fh, "%s%f", (j > 0) ? " ": "", vals[j]); } } // print ints if (set->shape.num_ints > 0) { const int * const vals = km_set_get_row_ints(set, i); for (size_t j = 0; j < set->shape.num_ints; j++) { const bool need_space = (set->shape.num_floats > 0) || (j > 0); fprintf(fh, "%s%d", need_space ? " ": "", vals[j]); } } // end row fprintf(fh, "\n"); } // return success return true; }