00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef CUEX_TAGMONOID_H
00019 #define CUEX_TAGMONOID_H
00020
00021 #include <cuex/fwd.h>
00022 #include <cuex/ltree.h>
00023
00024 CU_BEGIN_DECLARATIONS
00025
00026
00027
00028
00029
00030
00031
00032
00033
00034
00035
00036
00037
00038
00039
00040
00041
00042
00043
00044
00045
00046 typedef struct cuex_tmonoid *cuex_tmonoid_t;
00047 struct cuex_tmonoid
00048 {
00049 CUOO_HCOBJ
00050 cuex_meta_t opr;
00051 cuex_t ltree;
00052 };
00053
00054
00055
00056 #define CUEX_TMONOID_END CUEX_LTREE_END
00057
00058 extern cuoo_type_t cuexP_tmonoid_type;
00059
00060
00061 CU_SINLINE cuoo_type_t
00062 cuex_tmonoid_type()
00063 { return cuexP_tmonoid_type; }
00064
00065
00066 CU_SINLINE cu_bool_t
00067 cuex_is_tmonoid_type(cuex_t t)
00068 { return t == cuexP_tmonoid_type; }
00069
00070
00071 CU_SINLINE cu_bool_t
00072 cuex_is_tmonoid_meta(cuex_meta_t meta)
00073 { return meta == cuoo_type_to_meta(cuexP_tmonoid_type); }
00074
00075
00076 CU_SINLINE cu_bool_t
00077 cuex_any_tmonoid_contains(cuex_t x)
00078 { return cuex_meta(x) == cuoo_type_to_meta(cuex_tmonoid_type()); }
00079
00080
00081 CU_SINLINE cuex_meta_t
00082 cuex_tmonoid_opr(cuex_t x)
00083 { return ((cuex_tmonoid_t)x)->opr; }
00084
00085
00086 CU_SINLINE cu_bool_t
00087 cuex_tmonoid_contains(cuex_meta_t mult, cuex_t x)
00088 { return cuex_any_tmonoid_contains(x) && ((cuex_tmonoid_t)x)->opr == mult; }
00089
00090
00091 CU_SINLINE cu_bool_t
00092 cuex_tmonoid_is_identity(cuex_t x)
00093 { return cuex_ltree_is_empty(((cuex_tmonoid_t)x)->ltree); }
00094
00095
00096 CU_SINLINE cu_bool_t
00097 cuex_tmonoid_is_generator(cuex_t x)
00098 { return cuex_ltree_is_singleton(((cuex_tmonoid_t)x)->ltree); }
00099
00100
00101
00102 CU_SINLINE cu_bool_t
00103 cuex_tmonoid_is_composite(cuex_t x)
00104 { return cuex_ltree_is_composite(((cuex_tmonoid_t)x)->ltree); }
00105
00106
00107 cuex_t cuex_tmonoid_identity(cuex_meta_t mult);
00108
00109
00110 cuex_t cuex_tmonoid_generator(cuex_meta_t mult, cuex_t x);
00111
00112 cuex_t cuex_tmonoid_from_valist(cuex_meta_t mult, va_list vl);
00113
00114 cuex_t cuex_tmonoid_from_args(cuex_meta_t mult, ...);
00115
00116
00117
00118 cuex_t cuex_tmonoid_from_source(cuex_meta_t mult, cu_ptr_source_t src);
00119
00120
00121
00122 cuex_t cuex_tmonoid_from_array(cuex_meta_t mult,
00123 cuex_t *factor_arr, size_t factor_count);
00124
00125
00126
00127 cuex_t cuex_tmonoid_product(cuex_meta_t mult, cuex_t x, cuex_t y);
00128
00129
00130
00131 cuex_t cuex_any_tmonoid_product(cuex_t x, cuex_t y);
00132
00133
00134
00135 cuex_t cuex_tmonoid_rightmult(cuex_meta_t mult, cuex_t x, cuex_t y);
00136
00137
00138 cuex_t cuex_any_tmonoid_rightmult(cuex_t x, cuex_t y);
00139
00140
00141
00142 cuex_t cuex_tmonoid_rightmult_source(cuex_meta_t mult, cuex_t x,
00143 cu_ptr_source_t source);
00144
00145
00146 cuex_t cuex_any_tmonoid_rightmult_source(cuex_t x, cu_ptr_source_t source);
00147
00148
00149
00150 cuex_t cuex_tmonoid_rightmult_array(cuex_meta_t mult, cuex_t x,
00151 cuex_t *array, size_t count);
00152
00153
00154 cuex_t cuex_any_tmonoid_rightmult_array(cuex_t x, cuex_t *array, size_t count);
00155
00156 size_t cuex_tmonoid_length(cuex_meta_t mult, cuex_t x);
00157
00158 size_t cuex_any_tmonoid_length(cuex_t x);
00159
00160 cuex_t cuex_tmonoid_factor_at(cuex_meta_t mult, cuex_t x, ptrdiff_t i);
00161
00162 cuex_t cuex_any_tmonoid_factor_at(cuex_t x, ptrdiff_t i);
00163
00164 cuex_t cuex_tmonoid_factor_slice(cuex_meta_t mult, cuex_t x,
00165 ptrdiff_t i, ptrdiff_t j);
00166
00167 cuex_t cuex_any_tmonoid_factor_slice(cuex_t x, ptrdiff_t i, ptrdiff_t j);
00168
00169 cu_ptr_source_t cuex_tmonoid_factor_source(cuex_meta_t mult, cuex_t x,
00170 ptrdiff_t i, ptrdiff_t j);
00171
00172 cu_ptr_source_t cuex_any_tmonoid_factor_source(cuex_t x,
00173 ptrdiff_t i, ptrdiff_t j);
00174
00175 struct cuex_tmonoid_itr { struct cuex_ltree_itr sub; };
00176 typedef struct cuex_tmonoid_itr cuex_tmonoid_itr_t;
00177
00178 void cuex_tmonoid_itr_init_full(cuex_meta_t mult, cuex_tmonoid_itr_t *itr,
00179 cuex_t x);
00180
00181 void cuex_any_tmonoid_itr_init_full(cuex_tmonoid_itr_t *itr, cuex_t x);
00182
00183 void cuex_tmonoid_itr_init_slice(cuex_meta_t mult, cuex_tmonoid_itr_t *itr,
00184 cuex_t x, ptrdiff_t i, ptrdiff_t j);
00185
00186 void cuex_any_tmonoid_itr_init_slice(cuex_tmonoid_itr_t *itr,
00187 cuex_t x, ptrdiff_t i, ptrdiff_t j);
00188
00189 CU_SINLINE cuex_t cuex_tmonoid_itr_get(cuex_tmonoid_itr_t *itr)
00190 { return cuex_ltree_itr_get(&itr->sub); }
00191
00192 CU_SINLINE cu_bool_t cuex_tmonoid_itr_is_end(cuex_tmonoid_itr_t *itr)
00193 { return cuex_ltree_itr_is_end(&itr->sub); }
00194
00195
00196 CU_END_DECLARATIONS
00197
00198 #endif