Functions for instantiating and destroying ndpolator data structures. More...
Functions | |
| ndp_axis * | ndp_axis_new () |
| Default constructor for ndp_axis. | |
| ndp_axis * | ndp_axis_new_from_data (int len, double *val, int owns_data) |
| Constructor for ndp_axis from existing data. | |
| int | ndp_axis_free (ndp_axis *axis) |
| Destructor for ndp_axis. | |
| ndp_axes * | ndp_axes_new () |
| Default constructor for ndp_axes. | |
| ndp_axes * | ndp_axes_new_from_data (int naxes, int nbasic, ndp_axis **axis) |
| Constructor for ndp_axes from existing data. | |
| int | ndp_axes_free (ndp_axes *axes) |
| Destructor for ndp_axes. | |
| ndp_query_pts * | ndp_query_pts_new () |
| Default constructor for ndp_query_pts. | |
| ndp_query_pts * | ndp_query_pts_new_from_data (int nelems, int naxes, int *indices, int *flags, double *requested, double *normed) |
| Constructor for ndp_query_pts from existing data. | |
| int | ndp_query_pts_alloc (ndp_query_pts *qpts, int nelems, int naxes) |
| Allocates memory for ndp_query_pts arrays. | |
| int | ndp_query_pts_free (ndp_query_pts *qpts) |
| Destructor for ndp_query_pts. | |
| ndp_table * | ndp_table_new () |
| Default constructor for ndp_table. | |
| ndp_table * | ndp_table_new_from_data (ndp_axes *axes, int vdim, double *grid, int owns_data) |
| Constructor for ndp_table from existing data. | |
| int | ndp_table_free (ndp_table *table) |
| Destructor for ndp_table. | |
| ndp_hypercube * | ndp_hypercube_new () |
| Default constructor for ndp_hypercube. | |
| ndp_hypercube * | ndp_hypercube_new_from_data (int dim, int vdim, int fdhc, double *v) |
| Constructor for ndp_hypercube from existing data. | |
| int | ndp_hypercube_alloc (ndp_hypercube *hc, int dim, int vdim) |
| Allocates memory for ndp_hypercube vertex array. | |
| int | ndp_hypercube_free (ndp_hypercube *hc) |
| Destructor for ndp_hypercube. | |
| ndp_query * | ndp_query_new () |
| Default constructor for ndp_query. | |
| int | ndp_query_free (ndp_query *query) |
| Destructor for ndp_query. | |
Functions for instantiating and destroying ndpolator data structures.
Use these functions to properly allocate and free memory for ndpolator structures.
| ndp_axis * ndp_axis_new | ( | void | ) |
| ndp_axis * ndp_axis_new_from_data | ( | int | len, |
| double * | val, | ||
| int | owns_data ) |
Constructor for ndp_axis from existing data.
| len | Length of the val array |
| val | Array of vertices that span the axis |
| owns_data | Flag indicating if the val array is owned by self |
Initializes a new ndp_axis instance, sets axis->len to len and axis->val to val. Note that the function does not copy the array, it only assigns a pointer to it. Thus, the calling function needs to determine data ownership and pass an allocated copy if the array is (re)used elsewhere. Ndpolator treats the val array as read-only and will not change it. On destruction, the val array will be freed only if owns_data is set to true.
| int ndp_axis_free | ( | ndp_axis * | axis | ) |
Destructor for ndp_axis.
| axis | ndp_axis instance to be freed |
Frees memory allocated for the ndp_axis instance. This includes the val array memory and the ndp_axis instance itself.
| ndp_axes * ndp_axes_new | ( | void | ) |
Constructor for ndp_axes from existing data.
| naxes | Number of axes |
| nbasic | Number of basic axes |
| axis | Array of ndp_axis pointers |
Initializes a new ndp_axes instance, sets axes->len to naxes, axes->nbasic to nbasic, and axes->axis to axis. Note that the function does not copy the array, it only assigns a pointer to it. Thus, the calling function needs to pass an allocated copy if the array is (re)used elsewhere. Ndpolator treats the axis array as read-only and will not change it. On destruction, the axis array, along with all individual axis instances, will be freed.
| int ndp_axes_free | ( | ndp_axes * | axes | ) |
Destructor for ndp_axes.
| axes | ndp_axes instance to be freed |
Frees memory allocated for the ndp_axes instance. This includes the cplen array memory and the ndp_axes instance, along with all individual axis instances.
| ndp_query_pts * ndp_query_pts_new | ( | void | ) |
Default constructor for ndp_query_pts.
Initializes a new ndp_query_pts instance, sets nelems and naxes to 0, and sets indices, flags, requested, and normed array pointers to NULL.
| ndp_query_pts * ndp_query_pts_new_from_data | ( | int | nelems, |
| int | naxes, | ||
| int * | indices, | ||
| int * | flags, | ||
| double * | requested, | ||
| double * | normed ) |
Constructor for ndp_query_pts from existing data.
| nelems | Number of query points |
| naxes | Number of axes (query point dimension) |
| indices | Flattened array of parent hypercube indices, of length nelems * naxes |
| flags | Flattened array of ndp_vertex_flag flags, one for each query point component, of length nelems * naxes |
| requested | Flattened array of query points (in physical/axis units), of length nelems * naxes |
| normed | Flattened array of hypercube-normalized query points (in grid/tick units), of length nelems * naxes |
Initializes a new ndp_query_pts instance, sets nelems and naxes to the provided values, and points the indices, flags, requested, and normed arrays to the provided arrays. Memory for these arrays must be allocated by the caller. Ndpolator treats these arrays as read-only and will not change them. On destruction, the arrays will be freed along with the ndp_query_pts instance.
| int ndp_query_pts_alloc | ( | ndp_query_pts * | qpts, |
| int | nelems, | ||
| int | naxes ) |
Allocates memory for ndp_query_pts arrays.
| qpts | ndp_query_pts instance to allocate memory for |
| nelems | Number of query points |
| naxes | Number of axes (query point dimension) |
Allocates memory for the indices, flags, requested, and normed arrays; each array will be of length nelems * naxes.
| int ndp_query_pts_free | ( | ndp_query_pts * | qpts | ) |
Destructor for ndp_query_pts.
| qpts | ndp_query_pts instance to be freed |
Frees memory allocated for the ndp_query_pts instance. This includes the indices, flags, requested, and normed arrays.
| ndp_table * ndp_table_new | ( | void | ) |
Constructor for ndp_table from existing data.
| axes | ndp_axes instance defining all axes |
| vdim | Vertex dimension (function value length) |
| grid | Flattened array holding all function values, in C-native order, of size vdim * nverts |
| owns_data | Flag indicating if the grid array is owned by self |
Initializes a new ndp_table instance from passed data. Note that the function does not copy the arrays, it only assigns pointers to them. Thus, the calling function needs to determine data ownership and pass an allocated copy if the array is (re)used elsewhere. Ndpolator treats all arrays as read-only and will not change them. On destruction, the grid array will be freed only if owns_data is set to true.
This constructor also initializes a private list of all non-nan vertices and fully defined hypercubes in the grid. It does so by traversing the grid and storing their count in a private array. These fields are only used internally by ndpolator for the linear search of nearest neighbors and are likely to be made obsolete in the future.
| int ndp_table_free | ( | ndp_table * | table | ) |
Destructor for ndp_table.
| table | ndp_table instance to be freed |
Frees memory allocated for the ndp_table instance. This includes the axes, grid, vtree and hctree arrays. All private structures are also freed.
| ndp_hypercube * ndp_hypercube_new | ( | void | ) |
Default constructor for ndp_hypercube.
Initializes a new ndp_hypercube instance, sets dim and vdim to 0, fdhc to 0 (not fully defined), and vertex array v to NULL.
| ndp_hypercube * ndp_hypercube_new_from_data | ( | int | dim, |
| int | vdim, | ||
| int | fdhc, | ||
| double * | v ) |
Constructor for ndp_hypercube from existing data.
| dim | Dimension of the hypercube |
| vdim | Function value length |
| fdhc | Flag indicating whether hypercube is fully defined |
| v | Hypercube vertex function values |
Initializes a new ndp_hypercube instance and populates all fields from passed arguments. Note that the function does not copy the array, it only assigns a pointer to it. Thus, the calling function needs to pass an allocated copy if the array is (re)used elsewhere. Ndpolator treats the v array as read-only and it will not change it. On destruction, the v array is freed along with the ndp_hypercube instance.
| int ndp_hypercube_alloc | ( | ndp_hypercube * | hc, |
| int | dim, | ||
| int | vdim ) |
Allocates memory for ndp_hypercube vertex array.
| hc | ndp_hypercube instance to allocate memory for |
| dim | Dimension of the hypercube |
| vdim | Function value length |
Allocates memory for the vertex array v, of length vdim * 2^dim. It also sets the dim and vdim fields of the hypercube instance, and sets fdhc to 0 (not fully defined).
| int ndp_hypercube_free | ( | ndp_hypercube * | hc | ) |
Destructor for ndp_hypercube.
| hc | ndp_hypercube instance to be freed |
Frees memory allocated for the ndp_hypercube instance. This includes the vertex array v and the ndp_hypercube instance itself.
| ndp_query * ndp_query_new | ( | void | ) |
| int ndp_query_free | ( | ndp_query * | query | ) |
Destructor for ndp_query.
| query | ndp_query instance to be freed |
Frees memory allocated for the ndp_query instance. This includes the hypercubes, interps, and dists arrays, along with all individual hypercube instances.