diff --git a/parts/header_file/files/elc/_files/base_defs/magic_number.hpp b/parts/header_file/files/elc/_files/base_defs/magic_number.hpp index aeae09eb..815d1598 100644 --- a/parts/header_file/files/elc/_files/base_defs/magic_number.hpp +++ b/parts/header_file/files/elc/_files/base_defs/magic_number.hpp @@ -42,7 +42,7 @@ namespace magic_number{ constexpr auto gold_of_resize=gold+1;//精度2000——大概 /*! 圆周率. */ - constexpr auto pi = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009;//精度2000 + constexpr auto π = 3.14159265358979323846264338327950288419716939937510582097494459230781640628620899862803482534211706798214808651328230664709384460955058223172535940812848111745028410270193852110555964462294895493038196442881097566593344612847564823378678316527120190914564856692346034861045432664821339360726024914127372458700660631558817488152092096282925409171536436789259036001133053054882046652138414695194151160943305727036575959195309218611738193261179310511854807446237996274956735188575272489122793818301194912983367336244065664308602139494639522473719070217986094370277053921717629317675238467481846766940513200056812714526356082778577134275778960917363717872146844090122495343014654958537105079227968925892354201995611212902196086403441815981362977477130996051870721134999999837297804995105973173281609631859502445945534690830264252230825334468503526193118817101000313783875288658753320838142061717766914730359825349042875546873115956286388235378759375195778185778053217122680661300192787661119590921642019893809525720106548586327886593615338182796823030195203530185296899577362259941389124972177528347913151557485724245415069595082953311686172785588907509838175463746493931925506040092770167113900984882401285836160356370766010471018194295559619894676783744944825537977472684710404753464620804668425906949129331367702898915210475216205696602405803815019351125338243003558764024749647326391419927260426992279678235478163600934172164121992458631503028618297455570674983850549458858692699569092721079750930295532116534498720275596023648066549911988183479775356636980742654252786255181841757467289097777279380008164706001614524919217321721477235014144197356854816136115735255213347574184946843852332390739414333454776241686251898356948556209921922218427255025425688767179049460165346680498862723279178608578438382796797668145410095388378636095068006422512520511739298489608412848862694560424196528502221066118630674427862203919494504712371378696095636437191728746776465757396241389086583264599581339047802759009;//精度2000 /*! 自然对数的底数. */ constexpr auto e = 2.71828182845904523536028747135266249775724709369995957496696762772407663035354759457138217852516642742746639193200305992181741359662904357290033429526059563073813232862794349076323382988075319525101901157383418793070215408914993488416750924476146066808226480016847741185374234544243710753907774499206955170276183860626133138458300075204493382656029760673711320070932870912744374704723069697720931014169283681902551510865746377211125238978442505695369677078544996996794686445490598793163688923009879312773617821542499922957635148220826989519366803318252886939849646510582093923982948879332036250944311730123819706841614039701983767932068328237646480429531180232878250981945581530175671736133206981125099618188159304169035159888851934580727386673858942287922849989208680582574927961048419844436346324496848756023362482704197862320900216099023530436994184914631409343173814364054625315209618369088870701676839642437814059271456354906130310720851038375051011574770417189861068739696552126715468895703503540212340784981933432106817012100562788023519303322474501585390473041995777709350366041699732972508868769664035557071622684471625607988265178713419512466520198918006308407507245458379639351364421067750539471789004518357551541252235905906872648786357525419112888773717663748602766063496035367947026923229718683277173932361920077745221262475186983349515101986426988784717193966497690708252174233656627259284406204302141137199227852699846988477023238238400556555178890876613601304770984386116870523105531491625172837327286760072481729876375698163354150746088386636406934704372066886512756882661497307886570156850169186474885416791545965072342877306998537139043002665307839877638503238182155355973235306860430106757608389086270498418885951380910304235957824951439885901131858358406674723702971497850841458530857813391562707603563907639473114554958322669457024941398316343323789759556808568362972538679132750555425244919435891284050452269538121791319145135009938463117740179715122837854601160359554028644059;//精度2000 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 bfc6a5b1..fd0a36e9 100644 --- a/parts/header_file/files/elc/_files/base_defs/math.hpp +++ b/parts/header_file/files/elc/_files/base_defs/math.hpp @@ -435,15 +435,17 @@ namespace math{ 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 - if(!in_consteval)//编译期计算不能使用union_cast,让编译器慢慢算去吧 - if constexpr(is_big_type) - return quick_sqrt(static_cast(v)); - else{ - using namespace basic_environment::float_infos; - return union_cast((union_cast>(v)>>1) + (data_type(exponent_diff) << (precision_base_bit - 1))); - } + [[nodiscard]]inline constexpr T quick_sqrt(const T&v)noexcept{ + if constexpr(BIT_POSSIBILITY==2)// evil floating point bit level hacking + if(!in_consteval)//编译期计算不能使用union_cast,让编译器慢慢算去吧 + if constexpr(is_big_type) + return quick_sqrt(static_cast(v)); + else{ + using namespace basic_environment::float_infos; + return union_cast((union_cast>(v)>>1) + (data_type(exponent_diff) << (precision_base_bit - 1))); + } return v/2u; + //return reciprocal(quick_invsqrt(v)); } template [[nodiscard]]inline constexpr T sqrt(const T&v,const to_unsigned_t&ε,to_unsigned_t&ε_saver)noexcept{ @@ -932,7 +934,7 @@ namespace magic_number{ using ::std::move; template - struct pi_with_ε_impl_t{ + struct π_with_ε_impl_t{ private: typedef to_signed_t float_t; typedef to_unsigned_t ufloat_t; @@ -953,7 +955,7 @@ namespace magic_number{ size_t base_accurate = 0,sqrt_accuracy_multiplier = 1;//考虑到sqrt_iteration每次都会精度翻倍,而base_iteration每次只会精度增加14,所以我们可以通过追加这个值来省去一些不必要的sqrt迭代 public: - constexpr pi_with_ε_impl_t(ufloat_t the_ε = magic_number::god)noexcept: ε(move(the_ε)){} + constexpr π_with_ε_impl_t(ufloat_t the_ε = magic_number::god)noexcept: ε(move(the_ε)){} [[nodiscard]]constexpr T take_value()noexcept{ return abs(reciprocal(12u*result/sqrt_640320)); } @@ -1004,14 +1006,14 @@ namespace magic_number{ } }; template - distinctive inline pi_with_ε_impl_t pi_with_ε_impl{}; - distinctive inline constexpr struct pi_with_ε_t{ + distinctive inline π_with_ε_impl_t π_with_ε_impl{}; + distinctive inline constexpr struct π_with_ε_t{ template - static auto&_impl = pi_with_ε_impl>>; + static auto&_impl = π_with_ε_impl>>; template auto operator()(T&&ε)const noexcept{ if constexpr(is_basic_float_type) - return (T)magic_number::pi;//啊? + return (T)magic_number::π;//啊? else return _impl(forward(ε)); } @@ -1026,9 +1028,9 @@ namespace magic_number{ }; template static constexpr auto for_type = for_type_t{};//这个是为了让用户可以自己调用do_iteration等函数 - }pi_with_ε{}; + }π_with_ε{}; } -using magic_number::pi_with_ε; +using magic_number::π_with_ε; namespace math{ template @@ -1052,11 +1054,11 @@ namespace math{ [[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] + arctan (1/x) = 0.5 * π - arctan(x) [x > 0] */ if constexpr(signed_type) if (num < 0) return -arctan(abs(num), ε); - if (num > 1) return pi_with_ε(ε)/2u - arctan(reciprocal(move(num)), ε); + if (num > 1) return π_with_ε(ε)/2u - arctan(reciprocal(move(num)), ε); size_t i = 1; bool negation = false; // 取反 to_signed_t result = num; @@ -1077,7 +1079,7 @@ namespace math{ template [[nodiscard]]constexpr T cos(T num, const to_unsigned_t&ε)noexcept{ - return sin(pi_with_ε(ε)/2u - num, ε); + return sin(π_with_ε(ε)/2u - num, ε); } template requires(has_ε) [[nodiscard]]force_inline constexpr T cos(T num)noexcept{ @@ -1122,7 +1124,7 @@ namespace math{ template [[nodiscard]]constexpr to_unsigned_t arccos(T num, const to_unsigned_t&ε)noexcept{ - return to_unsigned_t(pi_with_ε(ε)/2u - arctan(num, ε)); + return to_unsigned_t(π_with_ε(ε)/2u - arctan(num, ε)); } template requires(has_ε) [[nodiscard]]force_inline constexpr to_unsigned_t arccos(T num)noexcept{ @@ -1140,7 +1142,7 @@ namespace math{ template [[nodiscard]]constexpr to_unsigned_t arccot(T num, const to_unsigned_t&ε)noexcept{ - return to_unsigned_t(pi_with_ε(ε)/2u - arctan(num, ε)); + return to_unsigned_t(π_with_ε(ε)/2u - arctan(num, ε)); } template requires(has_ε) [[nodiscard]]force_inline constexpr to_unsigned_t arccot(T num)noexcept{