SimpleNpyIOΒΆ

Simple library to read / write files in NPY format.

/**
 * @brief read NPY header
 * @param[out] ndim             : number of dimensions of the data set, e.g. 2
 * @param[out] shape            : number of points of the data set in each dimension, e.g. [3, 4]
 * @param[out] dtype            : data type, e.g. "'<f8'"
 * @param[out] is_fortran_order : row-major order (false) or column-major order (true)
 * @param[in]  fp               : file stream to which the header is loaded
 * @return                      : (success) loaded header size (in bytes)
 *                                (failure) 0
 */
extern size_t snpyio_r_header(
    size_t * ndim,
    size_t ** shape,
    char ** dtype,
    bool * is_fortran_order,
    FILE * fp
);
/**
 * @brief write NPY header
 * @param[in] ndim             : number of dimensions of the data set, e.g. 2
 * @param[in] shape            : number of points of the data set in each dimension, e.g. [3, 4]
 * @param[in] dtype            : data type, e.g. "'<f8'"
 * @param[in] is_fortran_order : row-major order (false) or column-major order (true)
 * @param[in] fp               : file stream to which the header is written
 * @return                     : (success) written header size (in bytes)
 *                               (failure) 0
 */
extern size_t snpyio_w_header(
    const size_t ndim,
    const size_t * shape,
    const char dtype[],
    const bool is_fortran_order,
    FILE * fp
);