From f8c8d9159a6f0c41dda076177e9cdfef0129fcd9 Mon Sep 17 00:00:00 2001 From: steve02081504 Date: Tue, 24 Oct 2023 21:48:11 +0800 Subject: [PATCH] Update --- parts/_share/_defs.hpp | 42 ++-- parts/_share/_undefs.hpp | 16 +- parts/_share/basic_environment/after_math.hpp | 8 +- parts/_share/basic_environment/pre_math.hpp | 4 +- parts/_share/char_set/convert.hpp | 14 +- .../_files/base/container/function/_test.hpp | 2 +- .../elc/_files/base/container/map/defs.hpp | 8 +- .../_files/base/container/stacks/_test.hpp | 2 +- .../elc/_files/base/memory/alloc/_test.hpp | 2 +- .../base/memory/gc/gc_flags/roots/_body.hpp | 2 +- .../memory/gc/gc_t/default_method/defs.hpp | 2 +- .../elc/_files/base/memory/gc/gc_t/defs.hpp | 2 +- .../base_defs/arithmetic_type_info_prover.hpp | 12 +- .../arithmetic_type_info_prover_decl.hpp | 4 +- .../files/elc/_files/base_defs/invoke.hpp | 12 +- .../files/elc/_files/base_defs/math.hpp | 236 +++++++++--------- .../base_stream/unreadable_wrap/_body.hpp | 2 +- .../files/elc/_files/bignum/_decl.hpp | 8 +- .../elc/_files/bignum/bignum/ubigint.hpp | 4 +- .../core/nodes/base_binary_function_node.hpp | 4 +- .../to_string/_body.hpp | 8 +- .../files/elc/resolve_global_name_conflicts | 4 +- .../test/elc-rand-testU01/output.txt | 36 +-- 23 files changed, 222 insertions(+), 212 deletions(-) diff --git a/parts/_share/_defs.hpp b/parts/_share/_defs.hpp index 49189b00..bbf1952b 100644 --- a/parts/_share/_defs.hpp +++ b/parts/_share/_defs.hpp @@ -212,33 +212,33 @@ class name{}\ #define was_not_an_ill_form_and_noexcept(...) (bool(requires{__VA_ARGS__;{__VA_ARGS__}noexcept;})) #define was_not_an_ill_form_with_parameter(...) (bool(requires __VA_ARGS__ )) -/*! 让lambda递归更加美观 */ -#define recursive_lambda(...) lambda(auto&&lambda_RLSRRS,__VA_ARGS__) -/*! 让lambda递归更加美观 */ -#define get_recursive_lambda_caller(name,...) \ -exlambda(auto&&...Args)__VA_ARGS__ lambda_force_inline{\ +/*! 让λ递归更加美观 */ +#define recursive_λ(...) λ(auto&&λ_RLSRRS,__VA_ARGS__) +/*! 让λ递归更加美观 */ +#define get_recursive_λ_caller(name,...) \ +exλ(auto&&...Args)__VA_ARGS__ λ_force_inline{\ return name(name,Args...);\ } -/*! 让lambda定义更加美观 */ -#define lambda [] -/*! 让lambda定义更加美观 */ -#define exlambda [&] -/*! 让lambda定义更加美观 */ -#define lambda_with_catch(...) [__VA_ARGS__] -/*! 让lambda定义更加美观 */ -#define self_recursion(...) lambda_RLSRRS(lambda_RLSRRS,__VA_ARGS__) -//recursive_lambda_self_referential_reserved_symbolname -#define lambda_RLSRRS _my_jb_super_sb_name_ +/*! 让λ定义更加美观 */ +#define λ [] +/*! 让λ定义更加美观 */ +#define exλ [&] +/*! 让λ定义更加美观 */ +#define λ_with_catch(...) [__VA_ARGS__] +/*! 让λ定义更加美观 */ +#define self_recursion(...) λ_RLSRRS(λ_RLSRRS,__VA_ARGS__) +//recursive_λ_self_referential_reserved_symbolname +#define λ_RLSRRS _my_jb_super_sb_name_ #if defined(_MSC_VER) && !defined(__clang__) - #define lambda_inline [[msvc::forceinline]] - #define lambda_force_inline [[msvc::forceinline]] + #define λ_inline [[msvc::forceinline]] + #define λ_force_inline [[msvc::forceinline]] #elif - #define lambda_inline [[gnu::always_inline]] - #define lambda_force_inline [[gnu::always_inline]] + #define λ_inline [[gnu::always_inline]] + #define λ_force_inline [[gnu::always_inline]] #else - #define lambda_inline - #define lambda_force_inline + #define λ_inline + #define λ_force_inline #endif #define MAGIC//ahh,ko no tenno da! diff --git a/parts/_share/_undefs.hpp b/parts/_share/_undefs.hpp index 430cea72..3480008f 100644 --- a/parts/_share/_undefs.hpp +++ b/parts/_share/_undefs.hpp @@ -124,15 +124,15 @@ #undef was_not_an_ill_form_and_noexcept #undef was_not_an_ill_form_with_parameter -#undef recursive_lambda -#undef get_recursive_lambda_caller -#undef lambda -#undef exlambda -#undef lambda_with_catch +#undef recursive_λ +#undef get_recursive_λ_caller +#undef λ +#undef exλ +#undef λ_with_catch #undef self_recursion -#undef lambda_RLSRRS -#undef lambda_inline -#undef lambda_force_inline +#undef λ_RLSRRS +#undef λ_inline +#undef λ_force_inline #undef MAGIC diff --git a/parts/_share/basic_environment/after_math.hpp b/parts/_share/basic_environment/after_math.hpp index 46efedc1..7524e710 100644 --- a/parts/_share/basic_environment/after_math.hpp +++ b/parts/_share/basic_environment/after_math.hpp @@ -46,7 +46,7 @@ namespace elc::defs{ /*! 给定大小的无符号整数类型 */ template - using unsigned_specific_size_t=decltype(lambda{ + using unsigned_specific_size_t=decltype(λ{ #define TYPE_MAPPER(type) if constexpr(size == sizeof(type))return (type)0;else #include "./arithmetic_mapper/unsigned_mapper.hpp" #undef TYPE_MAPPER @@ -54,7 +54,7 @@ namespace elc::defs{ }()); /*! 至少有给定大小的快速无符号整数类型 */ template - using unsigned_specific_size_fast_t=decltype(lambda{ + using unsigned_specific_size_fast_t=decltype(λ{ #define TYPE_MAPPER(type) if constexpr(size <= sizeof(type))return (type)0;else #include "./arithmetic_mapper/unsigned_fast_mapper.hpp" #undef TYPE_MAPPER @@ -62,7 +62,7 @@ namespace elc::defs{ }()); /*! 给定大小的有符号整数类型 */ template - using signed_specific_size_t=decltype(lambda{ + using signed_specific_size_t=decltype(λ{ #define TYPE_MAPPER(type) if constexpr(size == sizeof(type))return (type)0;else #include "./arithmetic_mapper/signed_mapper.hpp" #undef TYPE_MAPPER @@ -70,7 +70,7 @@ namespace elc::defs{ }()); /*! 至少有给定大小的快速有符号整数类型 */ template - using signed_specific_size_fast_t=decltype(lambda{ + using signed_specific_size_fast_t=decltype(λ{ #define TYPE_MAPPER(type) if constexpr(size <= sizeof(type))return (type)0;else #include "./arithmetic_mapper/signed_fast_mapper.hpp" #undef TYPE_MAPPER diff --git a/parts/_share/basic_environment/pre_math.hpp b/parts/_share/basic_environment/pre_math.hpp index d77a0eec..a4c167a4 100644 --- a/parts/_share/basic_environment/pre_math.hpp +++ b/parts/_share/basic_environment/pre_math.hpp @@ -67,7 +67,7 @@ namespace elc::defs{ typedef ::std::uintmax_t basic_uintmax_t; typedef ::std::intmax_t basic_intmax_t; //更新uintmax_t和intmax_t的代指 - typedef decltype(lambda{ + typedef decltype(λ{ #if defined(ELC_BASE_ENV_HAS_INT128) if constexpr(sizeof(basic_uintmax_t) < sizeof(uint128_t)) return uint128_t{}; @@ -75,7 +75,7 @@ namespace elc::defs{ #endif return basic_uintmax_t{}; }()) uintmax_t; - typedef decltype(lambda{ + typedef decltype(λ{ #if defined(ELC_BASE_ENV_HAS_INT128) if constexpr(sizeof(basic_intmax_t) < sizeof(int128_t)) return int128_t{}; diff --git a/parts/_share/char_set/convert.hpp b/parts/_share/char_set/convert.hpp index 1d912f93..ae8726c5 100644 --- a/parts/_share/char_set/convert.hpp +++ b/parts/_share/char_set/convert.hpp @@ -226,7 +226,7 @@ inline constexpr auto utf8_to_utf16(char16_t *out, const char8_t *in, size_t len //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -267,7 +267,7 @@ inline constexpr auto utf8_to_utf32(char32_t *out, const char8_t *in, size_t len //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -309,7 +309,7 @@ inline constexpr auto utf16_to_utf8(char8_t *out, const char16_t *in, size_t len //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -348,7 +348,7 @@ inline constexpr auto utf16_to_utf32(char32_t *out, const char16_t *in, size_t l //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -384,7 +384,7 @@ inline constexpr auto utf32_to_utf8(char8_t *out, const char32_t *in, size_t len //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -419,7 +419,7 @@ inline constexpr auto utf32_to_utf16(char16_t *out, const char32_t *in, size_t l //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ @@ -454,7 +454,7 @@ inline constexpr auto utf32_to_utf32(char32_t *out, const char32_t *in, size_t l //for return const auto out_start = out; const auto in_start = in; - auto result_builder = exlambda(bool success)noexcept{ + auto result_builder = exλ(bool success)noexcept{ return code_convert_result(success, string_view_t(in_start, in - in_start), string_view_t(out_start, out - out_start)); }; while(in < end){ diff --git a/parts/header_file/files/elc/_files/base/container/function/_test.hpp b/parts/header_file/files/elc/_files/base/container/function/_test.hpp index 18c6e097..6e8788d2 100644 --- a/parts/header_file/files/elc/_files/base/container/function/_test.hpp +++ b/parts/header_file/files/elc/_files/base/container/function/_test.hpp @@ -39,7 +39,7 @@ namespace function_n{ #else function_t #endif - a(lambda_with_catch (&tester)()noexcept{ tester=1; }); + a(λ_with_catch (&tester)()noexcept{ tester=1; }); static_assert(type_info == type_info>); stest_accert(tester==0); a(); diff --git a/parts/header_file/files/elc/_files/base/container/map/defs.hpp b/parts/header_file/files/elc/_files/base/container/map/defs.hpp index 00137c2c..185cb098 100644 --- a/parts/header_file/files/elc/_files/base/container/map/defs.hpp +++ b/parts/header_file/files/elc/_files/base/container/map/defs.hpp @@ -105,7 +105,7 @@ namespace map_n{ #define expr declvalue(func_t)(declvalue(T&)) template requires was_not_an_ill_form(expr) void for_each(func_t&&func)noexcept_as(expr){ - _m.for_each(lambda(data_t&a)noexcept_as(expr){ + _m.for_each(λ(data_t&a)noexcept_as(expr){ func(a._value); }); } @@ -114,7 +114,7 @@ namespace map_n{ #define expr declvalue(func_t)(declvalue(const T&)) template requires was_not_an_ill_form(expr) void for_each(func_t&&func)const noexcept_as(expr){ - _m.for_each(lambda(data_t&a)noexcept_as(expr){ + _m.for_each(λ(data_t&a)noexcept_as(expr){ func(add_const(a._value)); }); } @@ -122,7 +122,7 @@ namespace map_n{ static constexpr bool shrink_nothow=stack_t::remove_nothrow; void shrink()const noexcept(shrink_nothow){ - _m.for_each_bucket(lambda(stack_t&a)noexcept(shrink_nothow && equal.nothrow){ + _m.for_each_bucket(λ(stack_t&a)noexcept(shrink_nothow && equal.nothrow){ while(a.remove(data_t::seek_value_t(const_default_value_of))); }); } @@ -135,7 +135,7 @@ namespace map_n{ if(size()!=a.size()) return 0; try{ - _m.for_each(lambda_with_catch(&a)(data_t&b){ + _m.for_each(λ_with_catch(&a)(data_t&b){ if(a[b._key]!=b._value) throw (this_t*)(nullptr); }); diff --git a/parts/header_file/files/elc/_files/base/container/stacks/_test.hpp b/parts/header_file/files/elc/_files/base/container/stacks/_test.hpp index 1e04c022..582de380 100644 --- a/parts/header_file/files/elc/_files/base/container/stacks/_test.hpp +++ b/parts/header_file/files/elc/_files/base/container/stacks/_test.hpp @@ -40,7 +40,7 @@ inline void test(){ a.remove(2); stest_accert(a.size()==2); int add_num=0; - a.for_each(lambda_with_catch(&add_num)(int a){add_num+=a;}); + a.for_each(λ_with_catch(&add_num)(int a){add_num+=a;}); stest_accert(add_num==4); auto_stack_tb=a; stest_accert(b.not_in_stack(2)); diff --git a/parts/header_file/files/elc/_files/base/memory/alloc/_test.hpp b/parts/header_file/files/elc/_files/base/memory/alloc/_test.hpp index 881a46e9..ce0d032b 100644 --- a/parts/header_file/files/elc/_files/base/memory/alloc/_test.hpp +++ b/parts/header_file/files/elc/_files/base/memory/alloc/_test.hpp @@ -32,7 +32,7 @@ Checks for memory leaks. */ inline void check_memory_lack()noexcept{ - stest_mapeventlogwith(lambda(const void*p,steventlist*a)noexcept{ + stest_mapeventlogwith(λ(const void*p,steventlist*a)noexcept{ stest_putsf(L"内存泄露于%p,分配自:",p); stest_printeventlist(stdout,stest_copyeventlist(a)); //alloc_n::base_free(remove_const(p)); diff --git a/parts/header_file/files/elc/_files/base/memory/gc/gc_flags/roots/_body.hpp b/parts/header_file/files/elc/_files/base/memory/gc/gc_flags/roots/_body.hpp index 238e14a5..5c2141ca 100644 --- a/parts/header_file/files/elc/_files/base/memory/gc/gc_flags/roots/_body.hpp +++ b/parts/header_file/files/elc/_files/base/memory/gc/gc_flags/roots/_body.hpp @@ -51,7 +51,7 @@ class roots_t{ void map_and_mark()noexcept_as(declvalue(value_t)->map_and_mark()){ _roots.for_each( - lambda(value_t&a)noexcept_as(a->map_and_mark()) + λ(value_t&a)noexcept_as(a->map_and_mark()) { a->map_and_mark(); } diff --git a/parts/header_file/files/elc/_files/base/memory/gc/gc_t/default_method/defs.hpp b/parts/header_file/files/elc/_files/base/memory/gc/gc_t/default_method/defs.hpp index f9da4db6..68699cb6 100644 --- a/parts/header_file/files/elc/_files/base/memory/gc/gc_t/default_method/defs.hpp +++ b/parts/header_file/files/elc/_files/base/memory/gc/gc_t/default_method/defs.hpp @@ -66,7 +66,7 @@ namespace default_gc_for_type{ roots_of.map_and_mark(); if constexpr(info.has_attribute(can_shrink) || (info.has_attribute(mark_able_for_gc)&&info.has_attribute(have_root))) map_all( - lambda(T*a)noexcept{ + λ(T*a)noexcept{ if constexpr(info.has_attribute(can_shrink)) a->shrink(); if constexpr(info.has_attribute(mark_able_for_gc)&&info.has_attribute(have_root)){ diff --git a/parts/header_file/files/elc/_files/base/memory/gc/gc_t/defs.hpp b/parts/header_file/files/elc/_files/base/memory/gc/gc_t/defs.hpp index 8606e0fd..8aed5f62 100644 --- a/parts/header_file/files/elc/_files/base/memory/gc/gc_t/defs.hpp +++ b/parts/header_file/files/elc/_files/base/memory/gc/gc_t/defs.hpp @@ -49,7 +49,7 @@ class gc_t{ [[nodiscard]]inline bool success()const noexcept{ bool success=_gc_success_identifiers.empty(); _gc_success_identifiers.for_each( - lambda_with_catch(&success)(const success_identifier_t&a)noexcept{ + λ_with_catch(&success)(const success_identifier_t&a)noexcept{ if(not success) success=a(); } diff --git a/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover.hpp b/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover.hpp index c58700b7..e7db184e 100644 --- a/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover.hpp +++ b/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover.hpp @@ -110,14 +110,14 @@ namespace math{ } public: //bool:是否有默认极限值 - static constexpr bool has_epsilon=is_arithmetic_type; + static constexpr bool has_ε=is_arithmetic_type; public: - static constexpr auto epsilon()noexcept requires(has_epsilon){ + static constexpr auto ε()noexcept requires(has_ε){ return ::std::numeric_limits::epsilon(); } public: //对应的无符号和有符号类型 - using unsigned_type=decltype(lambda{ + using unsigned_type=decltype(λ{ if constexpr(type_info == type_info) return T(); elseif constexpr(is_float_type)//基础浮点类型没有对应的无符号 @@ -125,7 +125,7 @@ namespace math{ elseif constexpr(is_integer_type)//考虑到charX_t,所有整数类型都应该过一遍make_unsigned_t return::std::make_unsigned_t(); }()); - using signed_type=decltype(lambda{ + using signed_type=decltype(λ{ if constexpr(type_info == type_info) return T(); elseif constexpr(is_float_type) @@ -134,14 +134,14 @@ namespace math{ return::std::make_signed_t(); }()); //对应的浮点数类型 - using float_type=decltype(lambda{ + using float_type=decltype(λ{ if constexpr(is_float_type) return T(); elseif constexpr(is_integer_type) return .0; }()); //对应的整数类型 - using integer_type=decltype(lambda{ + using integer_type=decltype(λ{ if constexpr(is_integer_type) return T(); elseif constexpr(is_float_type) diff --git a/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover_decl.hpp b/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover_decl.hpp index e2e5036c..4870bd02 100644 --- a/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover_decl.hpp +++ b/parts/header_file/files/elc/_files/base_defs/arithmetic_type_info_prover_decl.hpp @@ -220,9 +220,9 @@ namespace math{ template concept has_min_max=has_min && has_max; - /// 有epsilon的类型概念 + /// 有ε的类型概念 template - concept has_epsilon=arithmetic_type_info_prover>::has_epsilon; + concept has_ε=arithmetic_type_info_prover>::has_ε; } } using math::to_unsigned_t; diff --git a/parts/header_file/files/elc/_files/base_defs/invoke.hpp b/parts/header_file/files/elc/_files/base_defs/invoke.hpp index 21def7df..b8326a88 100644 --- a/parts/header_file/files/elc/_files/base_defs/invoke.hpp +++ b/parts/header_file/files/elc/_files/base_defs/invoke.hpp @@ -60,30 +60,30 @@ struct invoke_t{ static constexpr bool nothrow= ::std::is_nothrow_invocable_r_v; /*! - A function that returns a lambda that applies a function to a value. + A function that returns a λ that applies a function to a value. @param rest The arguments to the function. - @returns A lambda that applies the function to a value. + @returns A λ that applies the function to a value. */ template requires able decltype(auto)_as(Args&&...rest)const noexcept(nothrow){//invoke.with_return_type._as(...) - return lambda_with_catch(rest...)(const T&a)noexcept(nothrow){return a(forward(rest)...);}; + return λ_with_catch(rest...)(const T&a)noexcept(nothrow){return a(forward(rest)...);}; } }; template static constexpr with_return_type_twith_return_type{}; /*! - A function that returns a lambda that applies a function to a value. + A function that returns a λ that applies a function to a value. @param rest The arguments to the function. - @returns A lambda that applies the function to a value. + @returns A λ that applies the function to a value. */ template requires able decltype(auto)_as(Args&&...rest)const noexcept(nothrow){//invoke._as(...) - return lambda_with_catch(rest...)(const T&a)noexcept(nothrow){return a(forward(rest)...);}; + return λ_with_catch(rest...)(const T&a)noexcept(nothrow){return a(forward(rest)...);}; } }; template diff --git a/parts/header_file/files/elc/_files/base_defs/math.hpp b/parts/header_file/files/elc/_files/base_defs/math.hpp index 25d0f183..ca1cb02e 100644 --- a/parts/header_file/files/elc/_files/base_defs/math.hpp +++ b/parts/header_file/files/elc/_files/base_defs/math.hpp @@ -203,7 +203,7 @@ namespace math{ template [[nodiscard]]force_inline constexpr bool is_close(const T&a,const T&b)noexcept{ if constexpr(basic_float_type) - return abs(a-b)<=arithmetic_type_info_prover::epsilon(); + return abs(a-b)<=arithmetic_type_info_prover::ε(); else return a==b; } @@ -226,20 +226,20 @@ namespace math{ template [[nodiscard]]force_inline constexpr T exp(const T&v)noexcept{ if(in_consteval||!is_basic_type){ - typedef decltype(lambda{ + typedef decltype(λ{ if constexpr(is_basic_type) return ::std::exp(T{}); else return T{}; }()) RT; - auto exp_impl = recursive_lambda(RT x,RT sum,RT n,size_t i,RT t)noexcept -> RT{ - const auto epsilon=sum+t/n; - if(is_close(sum,epsilon)) + auto exp_impl = recursive_λ(RT x,RT sum,RT n,size_t i,RT t)noexcept -> RT{ + const auto ε=sum+t/n; + if(is_close(sum,ε)) return sum; else - return self_recursion(x,epsilon,n*i,i+1,t*x); + return self_recursion(x,ε,n*i,i+1,t*x); }; - auto exp_impl_caller = get_recursive_lambda_caller(exp_impl); + auto exp_impl_caller = get_recursive_λ_caller(exp_impl); return exp_impl_caller(RT{v},RT{1u},RT{1u},2,RT{v}); } elseif constexpr(is_basic_type) @@ -250,20 +250,20 @@ namespace math{ template [[nodiscard]]force_inline constexpr auto log(const T&a)noexcept{ if(in_consteval||!is_basic_type){ - typedef decltype(lambda()noexcept{ + typedef decltype(λ()noexcept{ if constexpr(is_basic_type) return ::std::log(T{}); else return T{}; }()) RT; - auto log_impl = recursive_lambda(const RT x,const RT y)noexcept -> RT{ - auto log_iter = lambda(RT x,RT y)noexcept{ + auto log_impl = recursive_λ(const RT x,const RT y)noexcept -> RT{ + auto log_iter = λ(RT x,RT y)noexcept{ const auto exp_y = exp(y); return y + T{2u}*(x-exp_y)/(x+exp_y); }; return RT(is_close(y,log_iter(x,y)) ? y : self_recursion(x,log_iter(x,y))); }; - auto log_impl_caller = get_recursive_lambda_caller(log_impl); + auto log_impl_caller = get_recursive_λ_caller(log_impl); return log_impl_caller((RT)a,RT{0u}); } elseif constexpr(is_basic_type) @@ -276,7 +276,7 @@ namespace math{ //integer_log template [[nodiscard]]force_inline constexpr size_t integer_log(const T& a,const auto& b)noexcept{ - auto integer_log_impl = recursive_lambda(const T& a,T& tester,const T this_lv,const size_t num)noexcept -> size_t{ + auto integer_log_impl = recursive_λ(const T& a,T& tester,const T this_lv,const size_t num)noexcept -> size_t{ size_t aret=0; { const auto next_lv=this_lv*this_lv; @@ -290,7 +290,7 @@ namespace math{ aret+=num; } }; - auto integer_log_impl_caller = get_recursive_lambda_caller(integer_log_impl,noexcept); + auto integer_log_impl_caller = get_recursive_λ_caller(integer_log_impl,noexcept); T tester=1u; return integer_log_impl_caller(a,tester,move(b),1u); } @@ -339,7 +339,7 @@ namespace math{ template requires is_basic_type [[nodiscard]]force_inline constexpr auto ceil(const T&v)noexcept{ if in_consteval{ - auto ceil_impl = lambda(T x, T y)noexcept{ + auto ceil_impl = λ(T x, T y)noexcept{ return is_close(x,y) ? y : y+T{1}; }; return v<0 ? -static_cast(to_uintmax_t(-v)) : ceil_impl(v,static_cast(to_uintmax_t(v))); @@ -352,7 +352,7 @@ namespace math{ template requires is_basic_type [[nodiscard]]force_inline constexpr auto floor(const T&v)noexcept{ if in_consteval{ - auto floor_impl = lambda(T x, T y)noexcept{ + auto floor_impl = λ(T x, T y)noexcept{ return is_close(x,y) ? y : y-T{1}; }; return v<0 ? -static_cast(to_uintmax_t(-v+T{1})) : floor_impl(v,static_cast(to_uintmax_t(v))); @@ -361,7 +361,7 @@ namespace math{ return ::std::floor(v); } //invsqrt - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T invsqrt(const T&v)noexcept; template inline constexpr T invsqrt_iteration(const T&num,const T&v)noexcept{ @@ -369,10 +369,10 @@ namespace math{ return num*(3u-v*num*num)/2u; } template - inline constexpr T invsqrt_to_new_epsilon(T num,const T&v,const to_unsigned_t&epsilon,to_unsigned_t&epsilon_saver)noexcept{ - while(epsilon_saver>epsilon){ + inline constexpr T invsqrt_to_new_ε(T num,const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{ + while(ε_saver>ε){ auto next_ret=invsqrt_iteration(num,v); - epsilon_saver=abs(next_ret-num); + ε_saver=abs(next_ret-num); num=move(next_ret); } return num; @@ -390,30 +390,30 @@ namespace math{ return 2u/v; } template - [[nodiscard]]inline constexpr T invsqrt(const T&v,const to_unsigned_t&epsilon,to_unsigned_t&epsilon_saver)noexcept{ + [[nodiscard]]inline constexpr T invsqrt(const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{ if constexpr(has_NaN && has_inf) if(v < 0u || v >= arithmetic_type_info_prover::Inf()) return arithmetic_type_info_prover::NaN(); - return invsqrt_to_new_epsilon(quick_invsqrt(v),v,epsilon,epsilon_saver); + return invsqrt_to_new_ε(quick_invsqrt(v),v,ε,ε_saver); } template - [[nodiscard]]inline constexpr T invsqrt(const T&v,const to_unsigned_t&epsilon)noexcept{ + [[nodiscard]]inline constexpr T invsqrt(const T&v,const to_unsigned_t&ε)noexcept{ if constexpr(has_NaN && has_inf) if(v < 0u || v >= arithmetic_type_info_prover::Inf()) return arithmetic_type_info_prover::NaN(); - return invsqrt_to_new_epsilon(quick_invsqrt(v),v,epsilon); + return invsqrt_to_new_ε(quick_invsqrt(v),v,ε); } //invsqrt with one parameter - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T invsqrt(const T&v)noexcept{ - return invsqrt(v,arithmetic_type_info_prover::epsilon()); + return invsqrt(v,arithmetic_type_info_prover::ε()); } template [[nodiscard]]force_inline constexpr auto invsqrt(const T&v)noexcept{ return invsqrt(static_cast>(v)); } //sqrt - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T sqrt(const T&v)noexcept; template inline constexpr T sqrt_iteration(const T&num,const T&v)noexcept{ @@ -421,18 +421,18 @@ namespace math{ return (num+v/num)/2u; } template - inline constexpr T sqrt_to_new_epsilon(T num,const T&v,const to_unsigned_t&epsilon,to_unsigned_t&epsilon_saver)noexcept{ - while(epsilon_saver>epsilon){ + inline constexpr T sqrt_to_new_ε(T num,const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{ + while(ε_saver>ε){ auto next_ret=sqrt_iteration(num,v); - epsilon_saver=abs(next_ret-num); + ε_saver=abs(next_ret-num); num=move(next_ret); } return num; } template - inline constexpr T sqrt_to_new_epsilon(T num,const T&v,const to_unsigned_t&epsilon)noexcept{ - auto epsilon_saver=to_unsigned_t{num}; - return sqrt_to_new_epsilon(num,v,epsilon,epsilon_saver); + inline constexpr T sqrt_to_new_ε(T num,const T&v,const to_unsigned_t&ε)noexcept{ + auto ε_saver=to_unsigned_t{ε*BIT_POSSIBILITY}; + return sqrt_to_new_ε(num,v,ε,ε_saver); } template [[nodiscard]]inline constexpr T quick_sqrt(const T&v)noexcept{if constexpr(BIT_POSSIBILITY==2)// evil floating point bit level hacking @@ -446,23 +446,23 @@ namespace math{ return v/2u; } template - [[nodiscard]]inline constexpr T sqrt(const T&v,const to_unsigned_t&epsilon,to_unsigned_t&epsilon_saver)noexcept{ + [[nodiscard]]inline constexpr T sqrt(const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{ if constexpr(has_NaN && has_inf) if(v < 0u || v >= arithmetic_type_info_prover::Inf()) return arithmetic_type_info_prover::NaN(); - return sqrt_to_new_epsilon(quick_invsqrt(v),v,epsilon,epsilon_saver); + return sqrt_to_new_ε(quick_invsqrt(v),v,ε,ε_saver); } template - [[nodiscard]]inline constexpr T sqrt(const T&v,const to_unsigned_t&epsilon)noexcept{ + [[nodiscard]]inline constexpr T sqrt(const T&v,const to_unsigned_t&ε)noexcept{ if constexpr(has_NaN && has_inf) if(v < 0u || v >= arithmetic_type_info_prover::Inf()) return arithmetic_type_info_prover::NaN(); - return sqrt_to_new_epsilon(quick_invsqrt(v),v,epsilon); + return sqrt_to_new_ε(quick_invsqrt(v),v,ε); } //sqrt with one parameter - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T sqrt(const T&v)noexcept{ - return sqrt(v,arithmetic_type_info_prover::epsilon()); + return sqrt(v,arithmetic_type_info_prover::ε()); } template [[nodiscard]]force_inline constexpr auto sqrt(const T&v)noexcept{ @@ -694,7 +694,7 @@ namespace math{ template struct prime_factorization_table_t{ typedef prime_factorization_table_t this_t; - static constexpr size_t table_size=lambda{ + static constexpr size_t table_size=λ{ number_T i=2,m=number; size_t aret=0; while(m!=1){ @@ -764,7 +764,7 @@ namespace math{ template struct unique_prime_factorization_table_t{ typedef unique_prime_factorization_table_t this_t; - static constexpr size_t table_size=lambda{ + static constexpr size_t table_size=λ{ number_T i=2,m=number; size_t aret=0; while(m!=1){ @@ -869,11 +869,11 @@ using math::pow; using math::ceil; using math::floor; using math::invsqrt_iteration; -using math::invsqrt_to_new_epsilon; +using math::invsqrt_to_new_ε; using math::quick_invsqrt; using math::invsqrt; using math::sqrt_iteration; -using math::sqrt_to_new_epsilon; +using math::sqrt_to_new_ε; using math::quick_sqrt; using math::sqrt; using math::trunc; @@ -904,6 +904,8 @@ namespace bit{ using namespace bit;//干净的符号导出! namespace math{ + using ::std::move; + //求出最大公约数 template [[nodiscard]]inline auto gcd(T x, T y)noexcept{ @@ -921,7 +923,7 @@ namespace math{ x-=y; } // 返回 x 左移 shift 位的结果 - return x << shift; + return move(x) << shift; } } using math::gcd; @@ -930,7 +932,7 @@ namespace magic_number{ using ::std::move; template - struct pi_with_epsilon_impl_t{ + struct pi_with_ε_impl_t{ private: typedef to_signed_t float_t; typedef to_unsigned_t ufloat_t; @@ -938,16 +940,17 @@ namespace magic_number{ typedef to_unsigned_t uint_t; float_t result{}, sum=magic_number::god; - ufloat_t epsilon; + ufloat_t ε; uint_t k{}, _3k{}, _6k{}; bool sign = true; uint_t _545140134k_p13591409 = 13591409u; // 545140134*k+13591409 uint_t _3k_factorial = 1u, _6k_factorial = 1u, k_factorial_pow_3 = 1u; ufloat_t _640320 = 640320u; - ufloat_t sqrt_640320_epsilon_saver=_640320; - ufloat_t sqrt_640320 = sqrt(_640320,epsilon,sqrt_640320_epsilon_saver);//我们需要缓存这个与epsilon有关的值 以便在下一次更高精度的迭代中对缓存的值进行利用 + ufloat_t sqrt_640320_ε_saver=_640320; + ufloat_t sqrt_640320 = sqrt(_640320,ε,sqrt_640320_ε_saver);//我们需要缓存这个与ε有关的值 以便在下一次更高精度的迭代中对缓存的值进行利用 ufloat_t _640320_pow_3kplus1p5 = sqrt_640320*640320u;//初始值1.5次方 const uint_t _545140134_ = 545140134u; const uint_t _640320pow3 = pow(uint_t{640320u},3u); + size_t base_accurate = 0,sqrt_accuracy_multiplier = 1;//考虑到sqrt_iteration每次都会精度翻倍,而base_iteration每次只会精度增加14,所以我们可以通过追加这个值来省去一些不必要的sqrt迭代 constexpr void update_sqrt_640320(ufloat_t new_value)noexcept{ //首先 我们将result中的sqrt_640320去除. @@ -962,7 +965,7 @@ namespace magic_number{ _640320_pow_3kplus1p5 *= magic_number; } public: - constexpr pi_with_epsilon_impl_t(ufloat_t the_epsilon = magic_number::god)noexcept: epsilon(move(the_epsilon)){} + constexpr pi_with_ε_impl_t(ufloat_t the_ε = magic_number::god)noexcept: ε(move(the_ε)){} [[nodiscard]]constexpr T take_value()noexcept{ return abs(reciprocal(12*result)); } @@ -986,7 +989,12 @@ namespace magic_number{ update_sqrt_640320(sqrt_iteration(sqrt_640320,_640320)); } constexpr void do_iteration()noexcept{ - do_base_iteration();do_sqrt_iteration(); + do_base_iteration(); + base_accurate += 14; + if(base_accurate >> sqrt_accuracy_multiplier){ + do_sqrt_iteration(); + sqrt_accuracy_multiplier++; + } } constexpr void clean_up()noexcept{ simplify(_640320_pow_3kplus1p5); @@ -994,35 +1002,35 @@ namespace magic_number{ simplify(result); } [[nodiscard]]constexpr T operator()()noexcept{ - while (abs(sum) > epsilon) + while (abs(sum) > ε) do_base_iteration(); return take_value(); } - [[nodiscard]]constexpr T operator()(ufloat_t new_epsilon)noexcept{ - if(new_epsilon < epsilon){ - if(sqrt_640320_epsilon_saver>new_epsilon)//epsilon变小了,我们需要重新计算sqrt_640320 - update_sqrt_640320(sqrt_to_new_epsilon(sqrt_640320,_640320,new_epsilon,sqrt_640320_epsilon_saver)); - //更新epsilon. - epsilon = move(new_epsilon); + [[nodiscard]]constexpr T operator()(ufloat_t new_ε)noexcept{ + if(new_ε < ε){ + if(sqrt_640320_ε_saver>new_ε)//ε变小了,我们需要重新计算sqrt_640320 + update_sqrt_640320(sqrt_to_new_ε(sqrt_640320,_640320,new_ε,sqrt_640320_ε_saver)); + //更新ε. + ε = move(new_ε); } return operator()(); } }; template - distinctive inline pi_with_epsilon_impl_t pi_with_epsilon_impl{}; - distinctive inline constexpr struct pi_with_epsilon_t{ + distinctive inline pi_with_ε_impl_t pi_with_ε_impl{}; + distinctive inline constexpr struct pi_with_ε_t{ template - static auto&_impl = pi_with_epsilon_impl>>; + static auto&_impl = pi_with_ε_impl>>; template - auto operator()(T&&epsilon)const noexcept{ + auto operator()(T&&ε)const noexcept{ if constexpr(is_basic_float_type) return (T)magic_number::pi;//啊? else - return _impl(forward(epsilon)); + return _impl(forward(ε)); } template struct for_type_t{ - [[nodiscard]]auto operator()(T epsilon)const noexcept{return _impl(forward(epsilon));} + [[nodiscard]]auto operator()(T ε)const noexcept{return _impl(forward(ε));} void do_base_iteration()const noexcept{_impl.do_base_iteration();} void do_sqrt_iteration()const noexcept{_impl.do_sqrt_iteration();} void do_iteration()const noexcept{_impl.do_iteration();} @@ -1031,16 +1039,16 @@ namespace magic_number{ }; template static constexpr auto for_type = for_type_t{};//这个是为了让用户可以自己调用do_iteration等函数 - }pi_with_epsilon{}; + }pi_with_ε{}; } -using magic_number::pi_with_epsilon; +using magic_number::pi_with_ε; namespace math{ template - [[nodiscard]]constexpr T sin(T num, const to_unsigned_t&epsilon)noexcept{ + [[nodiscard]]constexpr T sin(T num, const to_unsigned_t&ε)noexcept{ size_t i = 1; bool negation = false; // 取反 T base = num, result = num, num_pow = pow(num); // 求num2的次方 - while (abs(base) > epsilon) { + while (abs(base) > ε) { base *= num_pow/((i+1)*(i+2)); // 求阶乘 negation = !negation; // 每次循环取反 result += reverse_sign_if(negation,base); // 求和 @@ -1048,20 +1056,20 @@ namespace math{ } return result; } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T sin(T num)noexcept{ - return sin(num, arithmetic_type_info_prover::epsilon()); + return sin(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T arctan(T num, const to_unsigned_t&epsilon)noexcept{ + [[nodiscard]]constexpr T arctan(T num, const to_unsigned_t&ε)noexcept{ /* arctan (-x) = -arctan(x) arctan (1/x) = 0.5 * pi - arctan(x) [x > 0] */ if constexpr(signed_type) - if (num < 0) return -arctan(abs(num), epsilon); - if (num > 1) return pi_with_epsilon(epsilon)/2u - arctan(reciprocal(move(num)), epsilon); + if (num < 0) return -arctan(abs(num), ε); + if (num > 1) return pi_with_ε(ε)/2u - arctan(reciprocal(move(num)), ε); size_t i = 1; bool negation = false; // 取反 to_signed_t result = num; @@ -1072,102 +1080,102 @@ namespace math{ sum = numerator_base/i; // 单步计算结果 result += reverse_sign_if(negation,sum); // 求和 i += 2; - }while (abs(sum) > epsilon); + }while (abs(sum) > ε); return (T)result; } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T arctan(T num)noexcept{ - return arctan(num, arithmetic_type_info_prover::epsilon()); + return arctan(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T cos(T num, const to_unsigned_t&epsilon)noexcept{ - return sin(pi_with_epsilon(epsilon)/2u - num, epsilon); + [[nodiscard]]constexpr T cos(T num, const to_unsigned_t&ε)noexcept{ + return sin(pi_with_ε(ε)/2u - num, ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T cos(T num)noexcept{ - return cos(num, arithmetic_type_info_prover::epsilon()); + return cos(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T tan(T num, const to_unsigned_t&epsilon)noexcept{ - return sin(num, epsilon)/cos(num, epsilon); + [[nodiscard]]constexpr T tan(T num, const to_unsigned_t&ε)noexcept{ + return sin(num, ε)/cos(num, ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T tan(T num)noexcept{ - return tan(num, arithmetic_type_info_prover::epsilon()); + return tan(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T cot(T num, const to_unsigned_t&epsilon)noexcept{ - return cos(num, epsilon)/sin(num, epsilon); + [[nodiscard]]constexpr T cot(T num, const to_unsigned_t&ε)noexcept{ + return cos(num, ε)/sin(num, ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T cot(T num)noexcept{ - return cot(num, arithmetic_type_info_prover::epsilon()); + return cot(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T sec(T num, const to_unsigned_t&epsilon)noexcept{ - return reciprocal(cos(num, epsilon)); + [[nodiscard]]constexpr T sec(T num, const to_unsigned_t&ε)noexcept{ + return reciprocal(cos(num, ε)); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T sec(T num)noexcept{ - return sec(num, arithmetic_type_info_prover::epsilon()); + return sec(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T csc(T num, const to_unsigned_t&epsilon)noexcept{ - return reciprocal(sin(num, epsilon)); + [[nodiscard]]constexpr T csc(T num, const to_unsigned_t&ε)noexcept{ + return reciprocal(sin(num, ε)); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T csc(T num)noexcept{ - return csc(num, arithmetic_type_info_prover::epsilon()); + return csc(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr to_unsigned_t arccos(T num, const to_unsigned_t&epsilon)noexcept{ - return to_unsigned_t(pi_with_epsilon(epsilon)/2u - arctan(num, epsilon)); + [[nodiscard]]constexpr to_unsigned_t arccos(T num, const to_unsigned_t&ε)noexcept{ + return to_unsigned_t(pi_with_ε(ε)/2u - arctan(num, ε)); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr to_unsigned_t arccos(T num)noexcept{ - return arccos(num, arithmetic_type_info_prover::epsilon()); + return arccos(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T arcsin(T num, const to_unsigned_t&epsilon)noexcept{ - return arctan(num/reciprocal(sqrt(1-pow(num), epsilon)), epsilon); + [[nodiscard]]constexpr T arcsin(T num, const to_unsigned_t&ε)noexcept{ + return arctan(num/reciprocal(sqrt(1-pow(num), ε)), ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T arcsin(T num)noexcept{ - return arcsin(num, arithmetic_type_info_prover::epsilon()); + return arcsin(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr to_unsigned_t arccot(T num, const to_unsigned_t&epsilon)noexcept{ - return to_unsigned_t(pi_with_epsilon(epsilon)/2u - arctan(num, epsilon)); + [[nodiscard]]constexpr to_unsigned_t arccot(T num, const to_unsigned_t&ε)noexcept{ + return to_unsigned_t(pi_with_ε(ε)/2u - arctan(num, ε)); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr to_unsigned_t arccot(T num)noexcept{ - return arccot(num, arithmetic_type_info_prover::epsilon()); + return arccot(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T arcsec(T num, const to_unsigned_t&epsilon)noexcept{ - return arccos(reciprocal(num), epsilon); + [[nodiscard]]constexpr T arcsec(T num, const to_unsigned_t&ε)noexcept{ + return arccos(reciprocal(num), ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T arcsec(T num)noexcept{ - return arcsec(num, arithmetic_type_info_prover::epsilon()); + return arcsec(num, arithmetic_type_info_prover::ε()); } template - [[nodiscard]]constexpr T arccsc(T num, const to_unsigned_t&epsilon)noexcept{ - return arcsin(reciprocal(num), epsilon); + [[nodiscard]]constexpr T arccsc(T num, const to_unsigned_t&ε)noexcept{ + return arcsin(reciprocal(num), ε); } - template requires(has_epsilon) + template requires(has_ε) [[nodiscard]]force_inline constexpr T arccsc(T num)noexcept{ - return arccsc(num, arithmetic_type_info_prover::epsilon()); + return arccsc(num, arithmetic_type_info_prover::ε()); } } using math::sin; diff --git a/parts/header_file/files/elc/_files/base_stream/unreadable_wrap/_body.hpp b/parts/header_file/files/elc/_files/base_stream/unreadable_wrap/_body.hpp index c98e34eb..435b607e 100644 --- a/parts/header_file/files/elc/_files/base_stream/unreadable_wrap/_body.hpp +++ b/parts/header_file/files/elc/_files/base_stream/unreadable_wrap/_body.hpp @@ -30,7 +30,7 @@ */ //warp for not_unreadable_istream to make it unreadable template requires not_unreadable_istream_class -struct unreadable_wrap:stream_T,instance_struct>,virtual decltype(lambda{ +struct unreadable_wrap:stream_T,instance_struct>,virtual decltype(λ{ if constexpr(noexcept_stream_class) { if constexpr(data_stream_class) return type_info; diff --git a/parts/header_file/files/elc/_files/bignum/_decl.hpp b/parts/header_file/files/elc/_files/bignum/_decl.hpp index 225b223e..6d0cd121 100644 --- a/parts/header_file/files/elc/_files/bignum/_decl.hpp +++ b/parts/header_file/files/elc/_files/bignum/_decl.hpp @@ -64,7 +64,7 @@ namespace base::math{ //bool:是否有max static constexpr bool has_max = false; //bool:是否有默认极限值 - static constexpr bool has_epsilon = false; + static constexpr bool has_ε = false; //对应的无符号和有符号类型 using unsigned_type = ubigint; using signed_type = bigint; @@ -99,7 +99,7 @@ namespace base::math{ //bool:是否有max static constexpr bool has_max = false; //bool:是否有默认极限值 - static constexpr bool has_epsilon = false; + static constexpr bool has_ε = false; //对应的无符号和有符号类型 using unsigned_type = ubigint; using signed_type = bigint; @@ -132,7 +132,7 @@ namespace base::math{ //bool:是否有max static constexpr bool has_max = false; //bool:是否有默认极限值 - static constexpr bool has_epsilon = false; + static constexpr bool has_ε = false; //对应的无符号和有符号类型 using unsigned_type = ubigfloat; using signed_type = bigfloat; @@ -167,7 +167,7 @@ namespace base::math{ //bool:是否有max static constexpr bool has_max = false; //bool:是否有默认极限值 - static constexpr bool has_epsilon = false; + static constexpr bool has_ε = false; //对应的无符号和有符号类型 using unsigned_type = ubigfloat; using signed_type = bigfloat; diff --git a/parts/header_file/files/elc/_files/bignum/bignum/ubigint.hpp b/parts/header_file/files/elc/_files/bignum/bignum/ubigint.hpp index 76d334d0..9a8843f0 100644 --- a/parts/header_file/files/elc/_files/bignum/bignum/ubigint.hpp +++ b/parts/header_file/files/elc/_files/bignum/bignum/ubigint.hpp @@ -248,7 +248,7 @@ class ubigint{ } //调试用,返回一个可以输出到流的内部结构查看器 [[nodiscard]]auto get_data_viewer()const noexcept{ - return lambda_with_catch(this)(auto&stream)noexcept->auto&{ + return λ_with_catch(this)(auto&stream)noexcept->auto&{ for(auto& i: _data) stream << i << U' '; return stream; @@ -632,7 +632,7 @@ class ubigint{ //除法实现 [[nodiscard]]static base_type div_with_base_no_optimisation(data_type&buf,base_type*a,data_view_type b)noexcept{ data_view_type tryto{a,b.size()+1}; - const calc_type dividend=exlambda{ + const calc_type dividend=exλ{ const base_type*p=tryto.rbegin(); auto tmp=calc_type(*p);tmp*=base_type_mod;tmp+=calc_type(p[-1]); return tmp; diff --git a/parts/header_file/files/elc/_files/core/nodes/base_binary_function_node.hpp b/parts/header_file/files/elc/_files/core/nodes/base_binary_function_node.hpp index 9606e1f3..d581cd20 100644 --- a/parts/header_file/files/elc/_files/core/nodes/base_binary_function_node.hpp +++ b/parts/header_file/files/elc/_files/core/nodes/base_binary_function_node.hpp @@ -35,13 +35,13 @@ struct base_binary_function_node:node_like,instance_struct func)noexcept:_func(func){} base_binary_function_node(function_t func)noexcept{ - _func = lambda_with_catch(func)(ptr p)mutable{ + _func = λ_with_catch(func)(ptr p)mutable{ func(p); return as_value(the_void); }; } base_binary_function_node(function_t func)noexcept{ - _func = lambda_with_catch(func)(ptr)mutable{ + _func = λ_with_catch(func)(ptr)mutable{ func(); return as_value(the_void); }; diff --git a/parts/header_file/files/elc/_files/numerical_representation/to_string/_body.hpp b/parts/header_file/files/elc/_files/numerical_representation/to_string/_body.hpp index 01842161..eac40f5d 100644 --- a/parts/header_file/files/elc/_files/numerical_representation/to_string/_body.hpp +++ b/parts/header_file/files/elc/_files/numerical_representation/to_string/_body.hpp @@ -304,7 +304,7 @@ namespace to_string_n{ } //舍入相关 const auto rounding_threshold=radix/2; - auto rounding=exlambda(bool skip_zeros,auto backup_updater,auto exp_updater)noexcept{ + auto rounding=exλ(bool skip_zeros,auto backup_updater,auto exp_updater)noexcept{ auto result=divmod(move(num),radix); if(skip_zeros)//处理多余的0 if(!result.mod){ @@ -323,11 +323,11 @@ namespace to_string_n{ //额外的舍入检查为了更精确的处理 if(num>info_threshold_base){ auto num_backup=num;auto exp_backup=exp; - auto backup_updater=exlambda(const auto&new_num,const auto&new_exp)noexcept{ + auto backup_updater=exλ(const auto&new_num,const auto&new_exp)noexcept{ num_backup=new_num;exp_backup=new_exp; }; auto exp_pows=pow((ubigint)radix,exp); - auto exp_updater=exlambda(const auto&)noexcept{exp_pows*=radix;}; + auto exp_updater=exλ(const auto&)noexcept{exp_pows*=radix;}; floop{ //首先进行舍入 rounding(true,backup_updater,exp_updater); @@ -438,7 +438,7 @@ namespace to_string_n{ const auto radix=_repres.get_radix(); { auto denominator_backup=denominator;//备份denominator用于在发现此为无限小数时继续输出(省去还原计算) - auto clear_backup=exlambda()noexcept{denominator_backup=decltype(denominator_backup){};};//即时清空denominator_backup以节省内存 + auto clear_backup=exλ()noexcept{denominator_backup=decltype(denominator_backup){};};//即时清空denominator_backup以节省内存 //化简为numerator*radix^exp { auto result=divmod(denominator,radix); diff --git a/parts/header_file/files/elc/resolve_global_name_conflicts b/parts/header_file/files/elc/resolve_global_name_conflicts index eda8cc62..4ac5b898 100644 --- a/parts/header_file/files/elc/resolve_global_name_conflicts +++ b/parts/header_file/files/elc/resolve_global_name_conflicts @@ -51,9 +51,11 @@ namespace elc::defs{ template constexpr auto&the_type_info=type_info; - templaterequires(has_epsilon) + templaterequires(has_ε) [[nodiscard]]force_inline constexpr T the_sqrt(const T&v){return sqrt(v);} template[[nodiscard]]force_inline constexpr auto the_sqrt(const T&v){return sqrt(v);} + template[[nodiscard]]inline constexpr T the_sqrt(const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{return sqrt(v,ε,ε_saver);} + template[[nodiscard]]inline constexpr T the_sqrt(const T&v,const to_unsigned_t&ε)noexcept{return sqrt(v,ε);} } namespace elc{ using defs::the_type_info; diff --git a/parts/header_file/test/elc-rand-testU01/output.txt b/parts/header_file/test/elc-rand-testU01/output.txt index 05cfad33..05e1cb27 100644 --- a/parts/header_file/test/elc-rand-testU01/output.txt +++ b/parts/header_file/test/elc-rand-testU01/output.txt @@ -614,11 +614,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 4611686018427387904 - Lambda = Poisson mean = 54.2101 + λ = Poisson mean = 54.2101 ---------------------------------------------------- -Total expected number = N*Lambda : 5421.01 +Total expected number = N*λ : 5421.01 Total observed number : 5310 p-value of test : 0.93 @@ -643,11 +643,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 9223372036854775808 - Lambda = Poisson mean = 216.8404 + λ = Poisson mean = 216.8404 ---------------------------------------------------- -Total expected number = N*Lambda : 4336.81 +Total expected number = N*λ : 4336.81 Total observed number : 4396 p-value of test : 0.19 @@ -672,11 +672,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 18446744073709551616 - Lambda = Poisson mean = 365.9182 + λ = Poisson mean = 365.9182 ---------------------------------------------------- -Total expected number = N*Lambda : 7318.36 +Total expected number = N*λ : 7318.36 Total observed number : 7263 p-value of test : 0.74 @@ -701,11 +701,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 9223372036854775808 - Lambda = Poisson mean = 216.8404 + λ = Poisson mean = 216.8404 ---------------------------------------------------- -Total expected number = N*Lambda : 4336.81 +Total expected number = N*λ : 4336.81 Total observed number : 4302 p-value of test : 0.70 @@ -730,11 +730,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 9223372036854775808 - Lambda = Poisson mean = 216.8404 + λ = Poisson mean = 216.8404 ---------------------------------------------------- -Total expected number = N*Lambda : 4336.81 +Total expected number = N*λ : 4336.81 Total observed number : 4416 p-value of test : 0.12 @@ -759,11 +759,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 18446744073709551616 - Lambda = Poisson mean = 365.9182 + λ = Poisson mean = 365.9182 ---------------------------------------------------- -Total expected number = N*Lambda : 7318.36 +Total expected number = N*λ : 7318.36 Total observed number : 7400 p-value of test : 0.17 @@ -788,11 +788,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 18446744073709551616 - Lambda = Poisson mean = 365.9182 + λ = Poisson mean = 365.9182 ---------------------------------------------------- -Total expected number = N*Lambda : 7318.36 +Total expected number = N*λ : 7318.36 Total observed number : 7272 p-value of test : 0.70 @@ -817,11 +817,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 18446744073709551616 - Lambda = Poisson mean = 365.9182 + λ = Poisson mean = 365.9182 ---------------------------------------------------- -Total expected number = N*Lambda : 7318.36 +Total expected number = N*λ : 7318.36 Total observed number : 7328 p-value of test : 0.46 @@ -846,11 +846,11 @@ smarsa_BirthdaySpacings test: Number of cells = d^t = 18446744073709551616 - Lambda = Poisson mean = 365.9182 + λ = Poisson mean = 365.9182 ---------------------------------------------------- -Total expected number = N*Lambda : 7318.36 +Total expected number = N*λ : 7318.36 Total observed number : 7366 p-value of test : 0.29