FUNCTION derive_function_domain
(func : maths_function) : tuple_space;
LOCAL typenames : SET OF STRING := stripped_typeof(func); tspace : tuple_space := make_listed_product_space ([]); shape : LIST OF positive_integer; sidxs : LIST OF INTEGER := [0]; itvl : finite_integer_interval; factors : LIST OF finite_integer_interval := []; is_uniform : BOOLEAN := TRUE; END_LOCAL; IF 'FINITE_FUNCTION' IN typenames THEN RETURN (derive_finite_function_domain (func\finite_function.pairs)); END_IF; IF 'CONSTANT_FUNCTION' IN typenames THEN RETURN (domain_from (func\constant_function.source_of_domain)); END_IF; IF 'SELECTOR_FUNCTION' IN typenames THEN RETURN (domain_from (func\selector_function.source_of_domain)); END_IF; IF 'ELEMENTARY_FUNCTION' IN typenames THEN RETURN (derive_elementary_function_domain (func\elementary_function.func_id)); END_IF; IF 'RESTRICTION_FUNCTION' IN typenames THEN RETURN (one_tuples_of (func\restriction_function.operand)); END_IF; IF 'REPACKAGING_FUNCTION' IN typenames THEN IF func\repackaging_function.input_repack = ro_nochange THEN RETURN (func\repackaging_function.operand.domain); END_IF; IF func\repackaging_function.input_repack = ro_wrap_as_tuple THEN RETURN (factor1 (func\repackaging_function.operand.domain)); END_IF; IF func\repackaging_function.input_repack = ro_unwrap_tuple THEN RETURN (one_tuples_of (func\repackaging_function.operand.domain)); END_IF; -- Unreachable, AS there is no other possible VALUE FOR input_repack. RETURN (?); END_IF; IF 'REINDEXED_ARRAY_FUNCTION' IN typenames THEN shape := shape_of_array(func\unary_generic_expression.operand); sidxs := func\reindexed_array_function.starting_indices; REPEAT i := 1 TO SIZEOF (shape); itvl := make_finite_integer_interval (sidxs[i], sidxs[i]+shape[i]-1); INSERT (factors, itvl, i-1); IF shape[i] <> shape[1] THEN is_uniform := FALSE; END_IF; END_REPEAT; IF is_uniform THEN RETURN (make_uniform_product_space (factors[1], SIZEOF (shape))); END_IF; RETURN (make_listed_product_space (factors)); END_IF; IF 'SERIES_COMPOSED_FUNCTION' IN typenames THEN RETURN (func\series_composed_function.operands[1].domain); END_IF; IF 'PARALLEL_COMPOSED_FUNCTION' IN typenames THEN RETURN (domain_from (func\parallel_composed_function.source_of_domain)); END_IF; IF 'EXPLICIT_TABLE_FUNCTION' IN typenames THEN shape := func\explicit_table_function.shape; sidxs[1] := func\explicit_table_function.index_base; REPEAT i := 1 TO SIZEOF (shape); itvl := make_finite_integer_interval (sidxs[1], sidxs[1]+shape[i]-1); INSERT (factors, itvl, i-1); IF shape[i] <> shape[1] THEN is_uniform := FALSE; END_IF; END_REPEAT; IF is_uniform THEN RETURN (make_uniform_product_space (factors[1], SIZEOF (shape))); END_IF; RETURN (make_listed_product_space (factors)); END_IF; IF 'HOMOGENEOUS_LINEAR_FUNCTION' IN typenames THEN RETURN (one_tuples_of (make_uniform_product_space (factor1 (func\homogeneous_linear_function.mat.range), func\homogeneous_linear_function.mat\explicit_table_function.shape [func\homogeneous_linear_function.sum_index]))); END_IF; IF 'GENERAL_LINEAR_FUNCTION' IN typenames THEN RETURN (one_tuples_of (make_uniform_product_space (factor1 (func\general_linear_function.mat.range), func\general_linear_function.mat\explicit_table_function.shape [func\general_linear_function.sum_index] - 1))); END_IF; IF 'B_SPLINE_BASIS' IN typenames THEN RETURN (one_tuples_of (make_finite_real_interval (func\b_spline_basis.repeated_knots[func\b_spline_basis.order], closed, func\b_spline_basis.repeated_knots[func\b_spline_basis.num_basis+1], closed))); END_IF; IF 'B_SPLINE_FUNCTION' IN typenames THEN REPEAT i := 1 TO SIZEOF (func\b_spline_function.basis); tspace := assoc_product_space (tspace, func\b_spline_function.basis[i].domain); END_REPEAT; RETURN (one_tuples_of (tspace)); END_IF; IF 'RATIONALIZE_FUNCTION' IN typenames THEN RETURN (func\rationalize_function.fun.domain); END_IF; IF 'PARTIAL_DERIVATIVE_FUNCTION' IN typenames THEN RETURN (func\partial_derivative_function.derivand.domain); END_IF; IF 'DEFINITE_INTEGRAL_FUNCTION' IN typenames THEN RETURN (derive_definite_integral_domain(func)); END_IF; IF 'ABSTRACTED_EXPRESSION_FUNCTION' IN typenames THEN REPEAT i := 1 TO SIZEOF (func\abstracted_expression_function.variables); tspace := assoc_product_space (tspace, one_tuples_of (values_space_of (func\abstracted_expression_function.variables[i]))); END_REPEAT; RETURN (tspace); END_IF; IF 'EXPRESSION_DENOTED_FUNCTION' IN typenames THEN RETURN (values_space_of (func\expression_denoted_function.expr)\function_space. domain_argument); END_IF; IF 'IMPORTED_POINT_FUNCTION' IN typenames THEN RETURN (one_tuples_of (make_listed_product_space ([]))); END_IF; IF 'IMPORTED_CURVE_FUNCTION' IN typenames THEN RETURN (func\imported_curve_function.parametric_domain); END_IF; IF 'IMPORTED_SURFACE_FUNCTION' IN typenames THEN RETURN (func\imported_surface_function.parametric_domain); END_IF; IF 'IMPORTED_VOLUME_FUNCTION' IN typenames THEN RETURN (func\imported_volume_function.parametric_domain); END_IF; IF 'APPLICATION_DEFINED_FUNCTION' IN typenames THEN RETURN (func\application_defined_function.explicit_domain); END_IF; -- Unreachable, AS no other subtypes OF maths_function are permissible without -- first modifying this FUNCTION TO account FOR them. RETURN (?); END_FUNCTION; -- derive_function_domain
|