§ <ˆj--ãó„—dZdgZddlmZddlmZddlmZGd„d¦«Ze dkre e¦«¦«d Sd S) z€ Machine arithmetic - determine the parameters of the floating-point arithmetic system Author: Pearu Peterson, September 2003 ÚMachAré)Úany)Úerrstateé)Ú set_modulecó2—eZdZdZeeed„dfd„Zd„Zd„ZdS)raw Diagnosing machine parameters. Attributes ---------- ibeta : int Radix in which numbers are represented. it : int Number of base-`ibeta` digits in the floating point mantissa M. machep : int Exponent of the smallest (most negative) power of `ibeta` that, added to 1.0, gives something different from 1.0 eps : float Floating-point number ``beta**machep`` (floating point precision) negep : int Exponent of the smallest power of `ibeta` that, subtracted from 1.0, gives something different from 1.0. epsneg : float Floating-point number ``beta**negep``. iexp : int Number of bits in the exponent (including its sign and bias). minexp : int Smallest (most negative) power of `ibeta` consistent with there being no leading zeros in the mantissa. xmin : float Floating-point number ``beta**minexp`` (the smallest [in magnitude] positive floating point number with full precision). maxexp : int Smallest (positive) power of `ibeta` that causes overflow. xmax : float ``(1-epsneg) * beta**maxexp`` (the largest [in magnitude] usable floating value). irnd : int In ``range(6)``, information on what kind of rounding is done in addition, and on how underflow is handled. ngrd : int Number of 'guard digits' used when truncating the product of two mantissas to fit the representation. epsilon : float Same as `eps`. tiny : float An alias for `smallest_normal`, kept for backwards compatibility. huge : float Same as `xmax`. precision : float ``- int(-log10(eps))`` resolution : float ``- 10**(-precision)`` smallest_normal : float The smallest positive floating point number with 1 as leading bit in the mantissa following IEEE-754. Same as `xmin`. smallest_subnormal : float The smallest positive floating point number with 0 as leading bit in the mantissa following IEEE-754. Parameters ---------- float_conv : function, optional Function that converts an integer or integer array to a float or float array. Default is `float`. int_conv : function, optional Function that converts a float or float array to an integer or integer array. Default is `int`. float_to_float : function, optional Function that converts a float array to float. Default is `float`. Note that this does not seem to do anything useful in the current implementation. float_to_str : function, optional Function that converts a single float to a string. Default is ``lambda v:'%24.16e' %v``. title : str, optional Title that is printed in the string representation of `MachAr`. See Also -------- finfo : Machine limits for floating point types. iinfo : Machine limits for integer types. References ---------- .. [1] Press, Teukolsky, Vetterling and Flannery, "Numerical Recipes in C++," 2nd ed, Cambridge University Press, 2002, p. 31. có —d|zS)Nz%24.16e©)Úvs úI/opt/cloudlinux/venv/lib64/python3.11/site-packages/numpy/core/_machar.pyúzMachAr.js € y°1¡}€ózPython floating point numbercóŠ—td¬¦«5| |||||¦«ddd¦«dS#1swxYwYdS)a! float_conv - convert integer to float (array) int_conv - convert float (array) to integer float_to_float - convert float array to float float_to_str - convert array float to str title - description of used floating point numbers Úignore)ÚunderN)rÚ_do_init)ÚselfÚ float_convÚint_convÚfloat_to_floatÚ float_to_strÚtitles r Ú__init__zMachAr.__init__hs§€õ˜HÐ %Ñ %Ô %ð Uð UØ �MŠM˜* h°À ÈeÑ TÔ TÐ Tð Uð Uð Uñ Uô Uð Uð Uð Uð Uð Uð Uð Uøøøð Uð Uð Uð Uð Uð Us ‘8¸<¿<cóì —d}d}|d¦«}||z} ||z } |} t|¦«D])} | | z} | |z} | | z }t||z | k¦«rnŒ*t|| |jfz¦«‚|}t|¦«D]/} ||z}| |z} || | z ¦«}t|dk¦«rnŒ0t|| |jfz¦«‚|}||¦«}d}|}t|¦«D].} |dz}||z}||z} | |z }t||z | k¦«rnŒ/t|| |jfz¦«‚|| z }|} t|¦«D])} | | z} | |z} | | z }t||z | k¦«rnŒ*t|| |jfz¦«‚| |z} d}t| | z | k¦«rd}| |z}||z} |dkrt| |z | k¦«rd}|dz}||z }|} t|¦«D]}| |z} Œ| }t|¦«D]M} || z } t| |z | k¦«rnH| |z} |dz }|dkrtdt ¦«z¦«‚ŒNt|| |jfz¦«‚| }| }| dz }|} t|¦«D])} || z} t| |z | k¦«rn$| |z} |dz}Œ*t|| |jfz¦«‚| }d}||z} |dkrt| |z|z | k¦«rd}d}d}|}||z} d}!t|¦«D]r} |}"|"|"z}||z} || z} t| | z| k¦«s tt |¦«|"k¦«rnA| |z}t||z|k¦«rn$|dz}||z}Œst|| |jfz¦«‚|d kr |dz}#||z}$n"d}#|}%||%kr|%|z}%|#dz}#||%k°|%|%zdz }$t|¦«D]„} |"}&|"|z}"|"|z} |"| z} t| | z| k¦«rZtt |"¦«|&k¦«r:|dz}| |z}t||z|"k¦«rt| |"k¦«rd}!|"}&nŒƒnt|| |jfz¦«‚| }'|$||zdz kr|d kr |$|$z}$|#dz}#|$|'z}(||!z}|dkr|(dz }(|(|'z}|dkr|s|(dz }(|d kr|(dz }(t| |"k¦«r|(dz }(||z })t|)|z|)k¦«r|||zz })|)|&|z|z|zz })|(|'zdz}t|¦«D]}*|dkr|)|)z})Œ|)|z})Œt |&||zz ¦«}+||_||_||_||¦«|_ ||¦«|_ ||_ ||¦«|_ ||¦«|_ ||_|#|_|'|_||&¦«|_||&¦«|_|(|_||)¦«|_||)¦«|_||_||_|j |_|j|_|j|_|j|_||j¦«|_||+¦«|_||+¦«|_ddl},tA|, !||j ¦«¦« ¦«|_"| | z| z| z| z}-|-|j" z}.||.¦«|_#||.¦«|_$dS) Ni'z'Did not converge after %d tries with %srééÿÿÿÿrézAcould not determine machine tolerance for 'negep', locals() -> %sé é)%ÚrangerÚ RuntimeErrorÚdtypeÚlocalsÚabsÚibetaÚitÚnegepÚepsnegÚ _str_epsnegÚmachepÚepsÚ_str_epsÚngrdÚiexpÚminexpÚxminÚ _str_xminÚmaxexpÚxmaxÚ _str_xmaxÚirndrÚepsilonÚtinyÚhugeÚsmallest_normalÚ_str_smallest_normalÚsmallest_subnormalÚ_str_smallest_subnormalÚmathÚintÚlog10Ú precisionÚ resolutionÚ_str_resolution)/rrrrrrÚ max_iterNÚmsgÚoneÚtwoÚzeroÚaÚ_ÚtempÚtemp1ÚbÚitempr%Úbetar&Úbetahr5Útempar'ÚbetainÚir(r*r+r-ÚkÚzÚtÚnxresÚyr.ÚmxÚizr0r/r2r3Újr;r=ÚtenrAs/ r rzMachAr._do_initzs6 €Øˆ Ø7ˆØˆj˜‰mŒmˆØ�C‰iˆØ�S‰yˆð ˆÝ�yÑ!Ô!ð 5ð 5ˆAØ�A‘ˆAØ�s‘7ˆDؘ1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ð õ˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4Ø ˆÝ�yÑ!Ô!ð 5ð 5ˆAØ�A‘ˆAØ�q‘5ˆDØ�H˜T !™VÑ$Ô$ˆEÝ�5˜A’:‰Œð Ø�ð õ˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4؈؈z˜%Ñ Ô ˆðˆØ ˆÝ�yÑ!Ô!ð 5ð 5ˆAØ�a‘ˆBØ�D‘ˆAØ�s‘7ˆDؘ1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ð õ˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4à�s‘ ˆØ ˆÝ�yÑ!Ô!ð 5ð 5ˆAØ�A‘ˆAØ�s‘7ˆDؘ1‘HˆEÝ�5˜3‘; $Ò&Ñ'Ô'ð Ø�ð õ˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4Ø�5‰yˆØˆÝ ˆt�A‰v˜Š~Ñ Ô ð ØˆDØ�D‘ˆØ�u‰}ˆØ �1Š9ˆ9�˜T %™Z¨4Ò/Ñ0Ô0ˆ9؈Dð�Q‘ˆØ�t‘ˆØ ˆÝ�u‘”ð ð ˆAØ�F‘ ˆAˆAØ ˆÝ�yÑ!Ô!ð 5ð 5ˆAؘ‘7ˆDÝ�4˜‘8˜tÒ#Ñ$Ô$ð Ø�Ø�D‘ˆAؘA‘IˆEà�qŠyˆyÝ"ð$AÝDJÁHÄHñ$NñOôOðOðõ˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4Ø�ˆØˆð�˜‘ˆØ ˆå�yÑ!Ô!ð 5ð 5ˆAؘ‘7ˆDÝ�4˜‘8˜tÒ#Ñ$Ô$ð Ø�Ø�D‘ˆAؘa‘ZˆFˆFå˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4؈ðˆØ�S‰yˆØ �1Š9ˆ9�˜T #™X¨™^¨tÒ3Ñ4Ô4ˆ9؈Dð ˆØ ˆØ ˆØ �#‰IˆØˆÝ�yÑ!Ô!ð 5ð 5ˆA؈AØ�!‘ˆAØ�#‘ˆAØ�Q‘3ˆDÝ�1�Q‘3˜$’;ÑÔð ¥3¥s¨1¡v¤v°¢{Ñ#3Ô#3ð Ø�ؘ6‘MˆEÝ�5˜‘: ’?Ñ#Ô#ð Ø�Ø�A‘ˆAØ�A‘ˆAˆAå˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4Ø �BŠ;ˆ;Ø�q‘5ˆDØ�Q‘ˆBˆBàˆD؈BØ�r’'�'ؘ%‘Z�ؘa‘x�ð�r’'�'ð�b‘˜1‘ˆBõ�yÑ!Ô!ð 5ð 5ˆA؈DØ�F‘ ˆAØ�C‘ˆAØ�q‘5ˆDÝ�A˜‘E˜d’?Ñ#Ô#ð ­­C°©F¬F°TªMÑ(:Ô(:ð Ø˜‘E�ؘv™ �Ý�u˜T‘z Q’Ñ'Ô'ð­C°¸² ©N¬NðØ�EØ�DØ�Eøà�å˜s a¨¬ ^Ñ3Ñ4Ô4Ð 4Ø�ˆð ��Q‘˜‘Š?ˆ?˜u¨š{˜{Ø�b‘ˆBؘ!‘8ˆDØ�f‘ˆØ�e‰|ˆØ �1Š9ˆ9ؘa‘ZˆFØ �V‰OˆØ �AŠ:ˆ:˜aˆ:ؘa‘ZˆFØ ˆrŠ6ˆ6ؘa‘ZˆFÝ ˆq�AŠv‰;Œ;ð Ø˜a‘ZˆFØ�V‰|ˆÝ ˆt�C‰x˜4ÒÑ Ô ð %ؘ˜f™Ñ$ˆDØ�t˜D‘y ‘~ dÑ*Ñ+ˆØ �V‰O˜aÑ ˆÝ�q‘”ð #ð #ˆAؘŠzˆzؘd‘{��à˜d‘{��å  ¨°© Ñ!4Ñ5Ô5ÐàˆŒ ؈ŒØˆŒ Ø$�n VÑ,Ô,ˆŒ Ø'˜<¨Ñ/Ô/ˆÔ؈Œ Ø!�> #Ñ&Ô&ˆŒØ$˜  SÑ)Ô)ˆŒ ؈Œ ؈Œ ؈Œ Ø"�N 4Ñ(Ô(ˆŒ Ø%˜ dÑ+Ô+ˆŒØˆŒ Ø"�N 4Ñ(Ô(ˆŒ Ø%˜ dÑ+Ô+ˆŒØˆŒ àˆŒ à”xˆŒ Ø”IˆŒ Ø”IˆŒ Ø#œyˆÔØ$0 L°´Ñ$;Ô$;ˆÔ!Ø"0 .Ð1CÑ"DÔ"DˆÔØ'3 |Ð4FÑ'GÔ'GˆÔ$àˆ ˆ ˆ ݘdŸjšj¨¨¸¼Ñ)AÔ)AÑBÔBÐBÑCÔCˆŒØ�C‰i˜#‰o Ñ# cÑ)ˆØ˜dœn˜_Ñ-ˆ Ø(˜.¨Ñ4Ô4ˆŒØ+˜|¨JÑ7Ô7ˆÔÐÐrcó—d}||jzS)NaCMachine parameters for %(title)s --------------------------------------------------------------------- ibeta=%(ibeta)s it=%(it)s iexp=%(iexp)s ngrd=%(ngrd)s irnd=%(irnd)s machep=%(machep)s eps=%(_str_eps)s (beta**machep == epsilon) negep =%(negep)s epsneg=%(_str_epsneg)s (beta**epsneg) minexp=%(minexp)s xmin=%(_str_xmin)s (beta**minexp == tiny) maxexp=%(maxexp)s xmax=%(_str_xmax)s ((1-epsneg)*beta**maxexp == huge) smallest_normal=%(smallest_normal)s smallest_subnormal=%(smallest_subnormal)s --------------------------------------------------------------------- )Ú__dict__)rÚfmts r Ú__str__zMachAr.__str__Ss€ð Uð ð�T”]Ñ"Ð"rN) Ú__name__Ú __module__Ú __qualname__Ú__doc__Úfloatr>rrr_r rr rrsn€€€€€ðTðTðl#(°Ø %Ø4Ð4Ø5ðUðUðUðUð$W8ðW8ðW8ðr #ð #ð #ð #ð #rÚ__main__N) rcÚ__all__Ú fromnumericrÚ _ufunc_configrÚ_utilsrrr`Úprintr rr úrks«ðððð ˆ*€àÐÐÐÐÐØ#Ð#Ð#Ð#Ð#Ð#ØÐÐÐÐÐð O#ðO#ðO#ðO#ðO#ñO#ôO#ðO#ðd  ˆzÒÐØ €Eˆ&ˆ&‰(Œ(�O„O€O€O€OðÐr