ESDM
Middleware for Earth System Data
Macros | Functions
hypercube.c File Reference

This file implements the hypercube related classes, esdmI_range_t, esdmI_hypercube_t, and esdmI_hypercubeSet_t. More...

#include <esdm-internal.h>
#include <inttypes.h>
#include <stdbool.h>
#include <stdlib.h>
#include <string.h>
Include dependency graph for hypercube.c:

Macros

#define _GNU_SOURCE   /* See feature_test_macros(7) */
 
#define makeIntersectionMatrix(list, out_intersectionMatrix, out_intersectionSizes)
 
#define findMinimalSubset(list, requiredCubes, intersectionMatrix, out_selectedCubes)
 

Functions

esdmI_range_t esdmI_range_intersection (esdmI_range_t a, esdmI_range_t b)
 
void esdmI_range_print (esdmI_range_t range, FILE *stream)
 
esdmI_hypercube_tesdmI_hypercube_makeDefault (int64_t dimensions)
 
esdmI_hypercube_tesdmI_hypercube_make (int64_t dimensions, int64_t *offset, int64_t *size)
 
esdmI_hypercube_tesdmI_hypercube_makeCopy (esdmI_hypercube_t *original)
 
esdmI_hypercube_tesdmI_hypercube_makeIntersection (esdmI_hypercube_t *a, esdmI_hypercube_t *b)
 
bool esdmI_hypercube_isEmpty (esdmI_hypercube_t *me)
 
uint32_t esdmI_hypercube_hash (const esdmI_hypercube_t *me)
 
uint32_t esdmI_hypercube_hashOffsetSize (int64_t dimCount, const int64_t *offset, const int64_t *size)
 
bool esdmI_hypercube_doesIntersect (esdmI_hypercube_t *a, esdmI_hypercube_t *b)
 
bool esdmI_hypercube_touches (esdmI_hypercube_t *a, esdmI_hypercube_t *b)
 
int64_t esdmI_hypercube_overlap (esdmI_hypercube_t *a, esdmI_hypercube_t *b)
 
bool esdmI_hypercube_equal (const esdmI_hypercube_t *a, const esdmI_hypercube_t *b)
 
double esdmI_hypercube_shapeSimilarity (esdmI_hypercube_t *a, esdmI_hypercube_t *b)
 
void esdmI_hypercube_getOffsetAndSize (const esdmI_hypercube_t *cube, int64_t *out_offset, int64_t *out_size)
 
int64_t esdmI_hypercube_size (esdmI_hypercube_t *cube)
 
void esdmI_hypercube_print (esdmI_hypercube_t *cube, FILE *stream)
 
void esdmI_hypercube_destroy (esdmI_hypercube_t *cube)
 
esdmI_hypercubeSet_tesdmI_hypercubeSet_make ()
 
void esdmI_hypercubeSet_construct (esdmI_hypercubeSet_t *me)
 
esdmI_hypercubeList_tesdmI_hypercubeSet_list (esdmI_hypercubeSet_t *me)
 
bool esdmI_hypercubeSet_isEmpty (esdmI_hypercubeSet_t *me)
 
int64_t esdmI_hypercubeSet_count (esdmI_hypercubeSet_t *me)
 
void esdmI_hypercubeSet_add (esdmI_hypercubeSet_t *me, esdmI_hypercube_t *cube)
 
void esdmI_hypercubeSet_subtract (esdmI_hypercubeSet_t *me, esdmI_hypercube_t *subtrahend)
 
bool esdmI_hypercubeList_doesIntersect (esdmI_hypercubeList_t *list, esdmI_hypercube_t *cube)
 
void esdmI_hypercubeList_nonredundantSubsets_internal (esdmI_hypercubeList_t *list, int64_t count, int64_t *inout_setCount, uint8_t(*out_subsets)[count])
 
bool esdmI_hypercubeList_doesCoverFully (esdmI_hypercubeList_t *list, esdmI_hypercube_t *cube)
 
void esdmI_hypercubeList_print (esdmI_hypercubeList_t *list, FILE *stream)
 
void esdmI_hypercubeSet_destruct (esdmI_hypercubeSet_t *me)
 
void esdmI_hypercubeSet_destroy (esdmI_hypercubeSet_t *me)
 

Detailed Description

This file implements the hypercube related classes, esdmI_range_t, esdmI_hypercube_t, and esdmI_hypercubeSet_t.

Macro Definition Documentation

◆ findMinimalSubset

#define findMinimalSubset (   list,
  requiredCubes,
  intersectionMatrix,
  out_selectedCubes 
)
Value:
do {\
esdmI_hypercubeList_t* l = list;\
findMinimalSubset_internal(l->count, l->cubes, requiredCubes, intersectionMatrix, out_selectedCubes);\
} while(false)

◆ makeIntersectionMatrix

#define makeIntersectionMatrix (   list,
  out_intersectionMatrix,
  out_intersectionSizes 
)
Value:
do {\
esdmI_hypercubeList_t* l = list;\
makeIntersectionMatrix_internal(l, l->count, out_intersectionMatrix, out_intersectionSizes);\
} while(false)

Function Documentation

◆ esdmI_hypercube_getOffsetAndSize()

void esdmI_hypercube_getOffsetAndSize ( const esdmI_hypercube_t cube,
int64_t *  out_offset,
int64_t *  out_size 
)

Return the shape of the hypercube as an offset and a size vector.

Parameters
[in]cubethe hypercube to get the shape of
[out]out_offsetarray of size cube->dims that will be filled with the offset vector components
[out]out_sizearray of size cube->dims that will be filled with the size vector components

◆ esdmI_hypercubeList_nonredundantSubsets_internal()

void esdmI_hypercubeList_nonredundantSubsets_internal ( esdmI_hypercubeList_t list,
int64_t  count,
int64_t *  inout_setCount,
uint8_t(*)  out_subsets[count] 
)

This function returns a number of minimal subsets of the cubes contained within the hypercubeList. The selection of the subsets is probabilistic as any complete algorithm I could think of would have had exponential complexity. The probabilistic solution allows the caller to specify how much effort should be spent in finding minimal subsets. With the probabilistic solution, the function creates as many subsets as indicated by *inout_setCount, and returns the number of actually found subsets in the same memory location. The returned value may be lower than the given value because a subset may be found several times.

The probabilistic algorithm is written in such a way that it will find small minimal subsets more easily than subsets that contain more cubes.

The complexity of the algorithm is O(*inout_setCount * list->count^2).

Parameters
[in]listthe hypercube list from which to select subsets
[in,out]inout_setCounton input the requested amount of subsets that are to be generated, on output the actual number of distinct subsets retured in out_subsets
[out]out_subsetsa 2D array of dimensions out_subsets[*inout_setCount][list->count] that will be used to store the flags which cube is selected for which subset; if out_subsets[i][j] is true then the cube with index j is selected for the subset i