Debian Codegraph @

src/H5Z-SPERR/include/h5zsperr_helper.h

raw
1 /*
2 * This file contains a few helper functions for the H5Z-SPERR filter.
3 */
4
5 #ifndef H5ZSPERR_HELPER_H
6 #define H5ZSPERR_HELPER_H
7
8 #include <stdlib.h>
9
10 #define LARGE_MAGNITUDE_F 1e35f
11 #define LARGE_MAGNITUDE_D 1e35
12 #define H5ZSPERR_COMPATIBILITY 1
13
14 #ifdef __cplusplus
15 namespace C_API {
16 extern "C" {
17 #endif
18
19 /*
20 * Pack and unpack additional information about the input data into an integer.
21 * It returns the encoded unsigned int, which shouldn't be zero.
22 * The packing function is called by `set_local()` to prepare information
23 * for `H5Z_filter_sperr()`, which calls the unpack function to extract such info.
24 */
25 unsigned int h5zsperr_pack_extra_info(int rank, int is_float, int missing_val_mode, int magic_num);
26 void h5zsperr_unpack_extra_info(unsigned int meta,
27 int* rank,
28 int* is_float,
29 int* missing_val_mode,
30 int* magic_num);
31
32 /*
33 * Check if an input array really has missing values.
34 */
35 int h5zsperr_has_nan(const void* buf, size_t nelem, int is_float);
36 int h5zsperr_has_large_mag(const void* buf, size_t nelem, int is_float);
37
38 /*
39 * Produce a compact bitmask.
40 * `mask_buf` is already allocated with length `mask_bytes`.
41 * Returns 0 upon success.
42 */
43 int h5zsperr_make_mask_nan(const void* data_buf, size_t nelem, int is_float,
44 void* mask_buf, size_t mask_bytes, size_t* useful_bytes);
45 int h5zsperr_make_mask_large_mag(const void* data_buf, size_t nelem, int is_float,
46 void* mask_buf, size_t mask_bytes, size_t* useful_bytes);
47
48 /*
49 * Replace every missing value in the `data_buf` with the mean of the field.
50 */
51 float h5zsperr_treat_nan_f32(float* data_buf, size_t nelem);
52 double h5zsperr_treat_nan_f64(double* data_buf, size_t nelem);
53 float h5zsperr_treat_large_mag_f32(float* data_buf, size_t nelem);
54 double h5zsperr_treat_large_mag_f64(double* data_buf, size_t nelem);
55
56 #ifdef __cplusplus
57 } /* end of extern "C" */
58 } /* end of namespace C_API */
59 #endif
60
61 #endif