#! /usr/bin/python3 typedef enum { ix_reduction_SINGLE, # ... *,*,*,0,1,2,3,4,5,*,*,*,*,*,*,*,*,*,* ... ix_reduction_EXTEND, # ... 0,0,0,0,1,2,3,4,5,5,5,5,5,5,5,5,5,5,5 ... ix_reduction_REPEAT, # ... 3,4,5,0,1,2,3,4,5,0,1,2,3,4,5,0,1,2,3 ... ix_reduction_MIRROR, # ... 2,1,0,0,1,2,3,4,5,5,4,3,2,1,0,0,1,2,3 ... ix_reduction_PXMIRR # ... 3,2,1,0,1,2,3,4,5,4,3,2,1,0,1,2,3,4,5 ... } ix_reduction_t; #define ix_reduction_FIRST ix_reduction_SINGLE #define ix_reduction_LAST ix_reduction_PXMIRR # A mapping from unrestricted {ix_index_t} values (positive or negative) to # integers in some range {0..N-1}. The comments above illustrate each mapping # for {N=6} and various indices from {-3} to {+15}. The code '*' denotes {-1}. # ELEMENT INDEXING ix_index_t ix_reduce ( ix_index_t i, ix_size_t N, ix_reduction_t red ); # Returns the index {i} reduced to {0..N-1} as specified by {red} void ix_reduce_range ( ix_index_t i0, ix_size_t m, ix_size_t N, ix_reduction_t red, ix_index_t i[] ); # Stores into {i[0..m-1]} the indices {i0..i0+m-1} reduced to {0..N-1} as specified by {red}.