This work will change the definitions of dim across the system to replace the current encoded dim.
This mainly occurs through usage of TYPES_DIM
and TCgetShapeDim
, but other dim usage shall be changed for possible future development that may find the dim_t implementation more useful.
The definition of dim_t is:
typedef struct DIM_T {
size_t val;
bool f_array_or_scalar: 1;
bool f_known_shape: 1;
bool f_known_dimension: 1;
} dim_t;
The tests created to verify correct function of TCgetShapeDim
currently highlight the possible types of dim results. These(with slight modification to use the struct instead of an int) will aid in later verifying that the modified dim still produces the required results.
This is the transition between the old and new definitions which shall be used to refactor the old usage of encoded dim:
TYPES_DIM can have the following values (and meanings):
* array, shape and dimension are know dim > SCALAR => val > SCALAR && f_known_shape
* array, shape is not known, dimension is known dim < KNOWN_DIM_OFFSET => val > SCALAR && f_known_dimension
* array, shape and dimension is not known dim == UNKNOWN_SHAPE => !f_known_shape && !f_known_dimension &&
!f_array_or_scalar
* array or scalar, shape and dimension are not known dim == ARRAY_OR_SCALAR => f_array_or_scalar
* scalar, shape and dimension are known dim == SCALAR => val == SCALAR && f_known_shape
Edit: Had to change flags for UNKNOWN_SHAPE to also check array_or_scalar as the previous check of only known shape or dimension was not enough. This would have left the chance that an array_or_scalar dim would also be unknown_shape, which is impossible following the rules of the previous version.