@@ -2588,6 +2588,79 @@ Literal lang_matches(Literal const &lang_tag, Literal const &lang_range, storage
25882588 auto const res = lang_matches (lang_tag.lexical_form (), lang_range.lexical_form ());
25892589 return Literal::make_boolean (res, lang_tag.select_node_storage (node_storage));
25902590}
2591+ Literal Literal::math_pi (storage::DynNodeStoragePtr node_storage) {
2592+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::numbers::pi, node_storage);
2593+ }
2594+
2595+ #define CPP_DOUBLE_OR_RETURN_NULL (source_expr, var_name ) \
2596+ auto const var_name##_opt = [&source_obj = (source_expr)]() -> std::optional<double > { \
2597+ if (source_obj.null ()) { \
2598+ return std::nullopt ; \
2599+ } \
2600+ if (!source_obj.datatype_eq <datatypes::xsd::Double>()) { \
2601+ return source_obj.cast_to_value <datatypes::xsd::Double>(); \
2602+ } \
2603+ return source_obj.value <datatypes::xsd::Double>(); \
2604+ }(); \
2605+ if (!var_name##_opt.has_value()) { \
2606+ return {}; \
2607+ } \
2608+ auto const var_name = *var_name##_opt;
2609+
2610+ Literal Literal::math_exp (storage::DynNodeStoragePtr node_storage) const {
2611+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2612+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::exp (th), select_node_storage (node_storage));
2613+ }
2614+ Literal Literal::math_exp10 (storage::DynNodeStoragePtr node_storage) const {
2615+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2616+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::pow (10.0 , th), select_node_storage (node_storage));
2617+ }
2618+ Literal Literal::math_log (storage::DynNodeStoragePtr node_storage) const {
2619+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2620+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::log (th), select_node_storage (node_storage));
2621+ }
2622+ Literal Literal::math_log10 (storage::DynNodeStoragePtr node_storage) const {
2623+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2624+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::log10 (th), select_node_storage (node_storage));
2625+ }
2626+ Literal Literal::math_pow (Literal exp, storage::DynNodeStoragePtr node_storage) const {
2627+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2628+ CPP_DOUBLE_OR_RETURN_NULL (exp, ex);
2629+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::pow (th, ex), select_node_storage (node_storage));
2630+ }
2631+ Literal Literal::math_sqrt (storage::DynNodeStoragePtr node_storage) const {
2632+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2633+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::sqrt (th), select_node_storage (node_storage));
2634+ }
2635+ Literal Literal::math_sin (storage::DynNodeStoragePtr node_storage) const {
2636+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2637+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::sin (th), select_node_storage (node_storage));
2638+ }
2639+ Literal Literal::math_cos (storage::DynNodeStoragePtr node_storage) const {
2640+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2641+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::cos (th), select_node_storage (node_storage));
2642+ }
2643+ Literal Literal::math_tan (storage::DynNodeStoragePtr node_storage) const {
2644+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2645+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::tan (th), select_node_storage (node_storage));
2646+ }
2647+ Literal Literal::math_asin (storage::DynNodeStoragePtr node_storage) const {
2648+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2649+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::asin (th), select_node_storage (node_storage));
2650+ }
2651+ Literal Literal::math_acos (storage::DynNodeStoragePtr node_storage) const {
2652+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2653+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::acos (th), select_node_storage (node_storage));
2654+ }
2655+ Literal Literal::math_atan (storage::DynNodeStoragePtr node_storage) const {
2656+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2657+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::atan (th), select_node_storage (node_storage));
2658+ }
2659+ Literal Literal::math_atan2 (Literal y, storage::DynNodeStoragePtr node_storage) const {
2660+ CPP_DOUBLE_OR_RETURN_NULL (*this , th);
2661+ CPP_DOUBLE_OR_RETURN_NULL (y, yd);
2662+ return Literal::make_typed_from_value<datatypes::xsd::Double>(std::atan2 (th, yd), select_node_storage (node_storage));
2663+ }
25912664
25922665inline namespace shorthands {
25932666
0 commit comments