This compound expression type aids in manipulating expressions of associative operators by keeping them in a canonical form. It implements a free monoid where the generators are arbitrary expressions. Further degeneracies, including handling of variables is left the client.
#define CUEX_MONOID_END CUEX_LTREE_END |
Special value for the end position of slicing operations to indicate slicing to the end.
cu_ptr_source_t cuex_any_monoid_factor_source | ( | cuex_t | e, | |
ptrdiff_t | i, | |||
ptrdiff_t | j | |||
) |
Returns a source which provides the factors i inclusive to j exclusive in the factorisation of x with respect to mult.
cu_bool_t cuex_check_monoid | ( | cuex_t | x, | |
cuex_meta_t * | mult_out | |||
) |
If x is a monoid (according to cuex_is_monoid_nongen), then set *mult_out
to the exact operator and return true, else return false.
True iff a monoid under any operator contains x as a non-generator.
cu_bool_t cuex_is_monoid_composite | ( | cuex_meta_t | mult, | |
cuex_t | x | |||
) |
True iff x is a composite element of the monoid under mult.
cu_bool_t cuex_is_monoid_identity | ( | cuex_meta_t | mult, | |
cuex_t | x | |||
) |
True iff x is the identity element of the monoid under mult.
cu_bool_t cuex_is_monoid_meta | ( | cuex_meta_t | meta | ) |
True iff meta is the meta of a monoid element.
cu_bool_t cuex_is_monoid_nongen | ( | cuex_meta_t | mult, | |
cuex_t | x | |||
) |
True iff x is a non-generator element of the monoid under mult. That is, if x is either the identity element or a composite element.
cuex_t cuex_monoid_factor_at | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
ptrdiff_t | i | |||
) |
Factor number i (counting from 0) of the factorisation of x with respect to mult. If i is negative it's taken to be relative to just past the last factor of x.
cuex_t cuex_monoid_factor_slice | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
ptrdiff_t | i, | |||
ptrdiff_t | j | |||
) |
The monoid of factors i inclusive to j exclusive of the factorisation of x, considering the operator mult.
cuex_t cuex_monoid_from_array | ( | cuex_meta_t | mult, | |
cuex_t * | factor_arr, | |||
size_t | factor_count | |||
) |
Returns a mult monoid element of factor_count factors from the array factor_arr.
cuex_t cuex_monoid_from_source | ( | cuex_meta_t | mult, | |
cu_ptr_source_t | source | |||
) |
Returns the mult-product of factors drawn from source in order.
cuex_t cuex_monoid_identity | ( | cuex_meta_t | mult | ) |
The identity element of the monoid induced by mult. This is the same for both unnested or nested cases.
cuex_t cuex_monoid_itr_get | ( | cuex_monoid_itr_t * | itr | ) |
Pops the next expression off itr or returns NULL
if itr is empty.
void cuex_monoid_itr_init_full | ( | cuex_meta_t | mult, | |
cuex_monoid_itr_t * | itr, | |||
cuex_t | x | |||
) |
Initialises itr for iterating over all mult-factors of x.
void cuex_monoid_itr_init_slice | ( | cuex_meta_t | mult, | |
cuex_monoid_itr_t * | itr, | |||
cuex_t | x, | |||
ptrdiff_t | i, | |||
ptrdiff_t | j | |||
) |
Initialises itr for iterating over mult-factors starting with number i and stopping at number j.
cu_bool_t cuex_monoid_itr_is_end | ( | cuex_monoid_itr_t * | itr | ) |
Checks if itr is empty without altering it.
size_t cuex_monoid_length | ( | cuex_meta_t | mult, | |
cuex_t | x | |||
) |
The number of factors in the factorisation of x with respect to mult.
cuex_meta_t cuex_monoid_opr | ( | cuex_t | x | ) |
Provided x is a monoid, returns it's operator. Do not call this without checking if x is a monoid.
cuex_t cuex_monoid_product | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
cuex_t | y | |||
) |
Returns x * y, where * = mult.
cuex_t cuex_monoid_rightmult | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
cuex_t | y | |||
) |
Returns x * y, where * = mult and y is treated as a single factor. If y is itself a monoid, the result is a nested monoid.
cuex_t cuex_monoid_rightmult_array | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
cuex_t * | array, | |||
size_t | count | |||
) |
The result of repeated application of cuex_monoid_rightmult, starting with x, for of the count expressions of the array as the last argument.
cuex_t cuex_monoid_rightmult_source | ( | cuex_meta_t | mult, | |
cuex_t | x, | |||
cu_ptr_source_t | source | |||
) |
The result of repeated application of cuex_monoid_rightmult, starting with x, for each expression drawn from source as the last argument.
cuoo_type_t cuex_monoid_type | ( | ) |
The object type of elements of monoid compounds.