pygeodesy 24.8.4__py2.py3-none-any.whl → 24.9.9__py2.py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {PyGeodesy-24.8.4.dist-info → PyGeodesy-24.9.9.dist-info}/METADATA +17 -16
- PyGeodesy-24.9.9.dist-info/RECORD +118 -0
- {PyGeodesy-24.8.4.dist-info → PyGeodesy-24.9.9.dist-info}/WHEEL +1 -1
- pygeodesy/__init__.py +23 -23
- pygeodesy/__main__.py +46 -47
- pygeodesy/auxilats/_CX_4.py +104 -181
- pygeodesy/auxilats/_CX_6.py +152 -277
- pygeodesy/auxilats/_CX_8.py +211 -438
- pygeodesy/auxilats/_CX_Rs.py +222 -0
- pygeodesy/auxilats/__init__.py +2 -2
- pygeodesy/auxilats/__main__.py +30 -38
- pygeodesy/auxilats/auxDST.py +2 -2
- pygeodesy/auxilats/auxLat.py +28 -36
- pygeodesy/auxilats/auxily.py +30 -50
- pygeodesy/basics.py +18 -7
- pygeodesy/booleans.py +10 -11
- pygeodesy/cartesianBase.py +5 -5
- pygeodesy/constants.py +35 -34
- pygeodesy/ellipsoidalBase.py +18 -15
- pygeodesy/ellipsoidalExact.py +2 -2
- pygeodesy/ellipsoidalGeodSolve.py +2 -2
- pygeodesy/ellipsoidalKarney.py +2 -2
- pygeodesy/ellipsoidalNvector.py +2 -2
- pygeodesy/ellipsoidalVincenty.py +7 -6
- pygeodesy/elliptic.py +154 -88
- pygeodesy/epsg.py +3 -3
- pygeodesy/etm.py +71 -59
- pygeodesy/fmath.py +99 -90
- pygeodesy/fsums.py +201 -14
- pygeodesy/gars.py +9 -8
- pygeodesy/geodesici.py +6 -5
- pygeodesy/geodesicx/_C4_24.py +1 -3
- pygeodesy/geodesicx/_C4_27.py +1 -3
- pygeodesy/geodesicx/_C4_30.py +1 -3
- pygeodesy/geodesicx/__init__.py +1 -1
- pygeodesy/geodesicx/__main__.py +44 -46
- pygeodesy/geodesicx/gx.py +3 -3
- pygeodesy/geodesicx/gxarea.py +5 -5
- pygeodesy/geodesicx/gxbases.py +32 -18
- pygeodesy/geodsolve.py +3 -3
- pygeodesy/geohash.py +18 -11
- pygeodesy/geoids.py +293 -315
- pygeodesy/heights.py +150 -158
- pygeodesy/internals.py +70 -9
- pygeodesy/interns.py +4 -4
- pygeodesy/karney.py +83 -60
- pygeodesy/ktm.py +4 -4
- pygeodesy/latlonBase.py +13 -7
- pygeodesy/lazily.py +13 -8
- pygeodesy/ltp.py +5 -6
- pygeodesy/ltpTuples.py +7 -1
- pygeodesy/mgrs.py +47 -42
- pygeodesy/named.py +8 -4
- pygeodesy/namedTuples.py +14 -1
- pygeodesy/osgr.py +7 -7
- pygeodesy/points.py +2 -2
- pygeodesy/props.py +7 -6
- pygeodesy/resections.py +7 -7
- pygeodesy/rhumb/__init__.py +1 -1
- pygeodesy/rhumb/aux_.py +42 -60
- pygeodesy/rhumb/solve.py +3 -3
- pygeodesy/simplify.py +10 -10
- pygeodesy/sphericalBase.py +3 -3
- pygeodesy/sphericalTrigonometry.py +2 -2
- pygeodesy/streprs.py +3 -3
- pygeodesy/triaxials.py +207 -201
- pygeodesy/units.py +3 -3
- pygeodesy/unitsBase.py +4 -4
- pygeodesy/utmupsBase.py +3 -3
- pygeodesy/vector2d.py +158 -51
- pygeodesy/vector3d.py +13 -52
- pygeodesy/vector3dBase.py +81 -63
- pygeodesy/webmercator.py +3 -3
- pygeodesy/wgrs.py +20 -22
- PyGeodesy-24.8.4.dist-info/RECORD +0 -117
- {PyGeodesy-24.8.4.dist-info → PyGeodesy-24.9.9.dist-info}/top_level.txt +0 -0
pygeodesy/fmath.py
CHANGED
|
@@ -14,7 +14,7 @@ from pygeodesy.constants import EPS0, EPS02, EPS1, NAN, PI, PI_2, PI_4, \
|
|
|
14
14
|
from pygeodesy.errors import _IsnotError, LenError, _TypeError, _ValueError, \
|
|
15
15
|
_xError, _xkwds_get1, _xkwds_pop2
|
|
16
16
|
from pygeodesy.fsums import _2float, Fsum, fsum, fsum1_, _isFsumTuple, _1primed, \
|
|
17
|
-
|
|
17
|
+
Fmt, unstr
|
|
18
18
|
from pygeodesy.interns import MISSING, _negative_, _not_scalar_
|
|
19
19
|
from pygeodesy.lazily import _ALL_LAZY, _sys_version_info2
|
|
20
20
|
# from pygeodesy.streprs import Fmt, unstr # from .fsums
|
|
@@ -24,10 +24,10 @@ from math import fabs, sqrt # pow
|
|
|
24
24
|
import operator as _operator # in .datums, .trf, .utm
|
|
25
25
|
|
|
26
26
|
__all__ = _ALL_LAZY.fmath
|
|
27
|
-
__version__ = '24.
|
|
27
|
+
__version__ = '24.09.09'
|
|
28
28
|
|
|
29
|
-
# sqrt(2) <https://WikiPedia.org/wiki/Square_root_of_2>
|
|
30
|
-
_0_4142 = 0.41421356237309504880 # ...
|
|
29
|
+
# sqrt(2) - 1 <https://WikiPedia.org/wiki/Square_root_of_2>
|
|
30
|
+
_0_4142 = 0.41421356237309504880 # ... ~ 3730904090310553 / 9007199254740992
|
|
31
31
|
_2_3rd = _1_3rd * 2
|
|
32
32
|
_h_lt_b_ = 'abs(h) < abs(b)'
|
|
33
33
|
|
|
@@ -36,13 +36,10 @@ class Fdot(Fsum):
|
|
|
36
36
|
'''Precision dot product.
|
|
37
37
|
'''
|
|
38
38
|
def __init__(self, a, *b, **name_RESIDUAL):
|
|
39
|
-
'''New L{Fdot} precision dot product M{sum(a[i] * b[i] for
|
|
40
|
-
i=0..len(a)-1)}.
|
|
39
|
+
'''New L{Fdot} precision dot product M{sum(a[i] * b[i] for i=0..len(a)-1)}.
|
|
41
40
|
|
|
42
|
-
@arg a: Iterable of values (each C{scalar}
|
|
43
|
-
|
|
44
|
-
@arg b: Other values (each C{scalar} or an L{Fsum} or L{Fsum2Tuple} instance),
|
|
45
|
-
all positional.
|
|
41
|
+
@arg a: Iterable of values (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
42
|
+
@arg b: Other values (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}), all positional.
|
|
46
43
|
@kwarg name_RESIDUAL: Optional C{B{name}=NN} (C{str}) and the C{B{RESIDUAL}=0.0}
|
|
47
44
|
threshold (C{scalar}) for raising L{ResidualError}s, see class
|
|
48
45
|
L{Fsum<Fsum.__init__>}.
|
|
@@ -64,14 +61,16 @@ class Fdot(Fsum):
|
|
|
64
61
|
class Fhorner(Fsum):
|
|
65
62
|
'''Precision polynomial evaluation using the Horner form.
|
|
66
63
|
'''
|
|
67
|
-
def __init__(self, x, *cs, **
|
|
68
|
-
'''New L{Fhorner} evaluation of polynomial M{sum(cs[i] * x**i for
|
|
69
|
-
i=0
|
|
64
|
+
def __init__(self, x, *cs, **incx_name_RESIDUAL):
|
|
65
|
+
'''New L{Fhorner} evaluation of polynomial M{sum(cs[i] * x**i for i=0..n)} if
|
|
66
|
+
C{B{incx}=False} for decreasing exponent M{sum(... i=n..0)} where C{n =
|
|
67
|
+
len(cs) - 1}.
|
|
70
68
|
|
|
71
|
-
@arg x: Polynomial argument (C{scalar}
|
|
72
|
-
@arg cs: Polynomial coeffients (each C{scalar}
|
|
73
|
-
|
|
74
|
-
@kwarg
|
|
69
|
+
@arg x: Polynomial argument (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
70
|
+
@arg cs: Polynomial coeffients (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}),
|
|
71
|
+
all positional.
|
|
72
|
+
@kwarg incx_name_RESIDUAL: Optional C{B{name}=NN} (C{str}), C{B{incx}=True}
|
|
73
|
+
for in-/decreasing exponents (C{bool}) and the C{B{RESIDUAL}=0.0}
|
|
75
74
|
threshold (C{scalar}) for raising L{ResidualError}s, see class
|
|
76
75
|
L{Fsum<Fsum.__init__>}.
|
|
77
76
|
|
|
@@ -83,9 +82,10 @@ class Fhorner(Fsum):
|
|
|
83
82
|
|
|
84
83
|
@see: Function L{fhorner} and methods L{Fsum.fadd} and L{Fsum.fmul}.
|
|
85
84
|
'''
|
|
85
|
+
incx, name_RESIDUAL = _xkwds_pop2(incx_name_RESIDUAL, incx=True)
|
|
86
86
|
Fsum.__init__(self, **name_RESIDUAL)
|
|
87
87
|
if cs:
|
|
88
|
-
self._fhorner(x, cs, Fhorner.__name__)
|
|
88
|
+
self._fhorner(x, cs, Fhorner.__name__, incx=incx)
|
|
89
89
|
else:
|
|
90
90
|
self._fset_ps(_0_0)
|
|
91
91
|
|
|
@@ -94,11 +94,11 @@ class Fhypot(Fsum):
|
|
|
94
94
|
'''Precision summation and hypotenuse, default C{root=2}.
|
|
95
95
|
'''
|
|
96
96
|
def __init__(self, *xs, **root_name_RESIDUAL_raiser):
|
|
97
|
-
'''New L{Fhypot} hypotenuse of (the I{root} of) several components
|
|
98
|
-
|
|
97
|
+
'''New L{Fhypot} hypotenuse of (the I{root} of) several components (raised
|
|
98
|
+
to the power I{root}).
|
|
99
99
|
|
|
100
|
-
@arg xs: Components (each C{scalar}
|
|
101
|
-
|
|
100
|
+
@arg xs: Components (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}), all
|
|
101
|
+
positional.
|
|
102
102
|
@kwarg root_name_RESIDUAL_raiser: Optional, exponent and C{B{root}=2} order
|
|
103
103
|
(C{scalar}), C{B{name}=NN} (C{str}), the C{B{RESIDUAL}=0.0}
|
|
104
104
|
threshold (C{scalar}) and C{B{raiser}=True} (C{bool}) for
|
|
@@ -121,12 +121,12 @@ class Fpolynomial(Fsum):
|
|
|
121
121
|
'''Precision polynomial evaluation.
|
|
122
122
|
'''
|
|
123
123
|
def __init__(self, x, *cs, **name_RESIDUAL):
|
|
124
|
-
'''New L{Fpolynomial} evaluation of the polynomial
|
|
125
|
-
|
|
124
|
+
'''New L{Fpolynomial} evaluation of the polynomial M{sum(cs[i] * x**i for
|
|
125
|
+
i=0..len(cs)-1)}.
|
|
126
126
|
|
|
127
|
-
@arg x: Polynomial argument (C{scalar}
|
|
128
|
-
@arg cs: Polynomial coeffients (each C{scalar}
|
|
129
|
-
|
|
127
|
+
@arg x: Polynomial argument (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
128
|
+
@arg cs: Polynomial coeffients (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}),
|
|
129
|
+
all positional.
|
|
130
130
|
@kwarg name_RESIDUAL: Optional C{B{name}=NN} (C{str}) and the C{B{RESIDUAL}=0.0}
|
|
131
131
|
threshold (C{scalar}) for raising L{ResidualError}s, see class
|
|
132
132
|
L{Fsum<Fsum.__init__>}.
|
|
@@ -153,9 +153,9 @@ class Fpowers(Fsum):
|
|
|
153
153
|
def __init__(self, power, *xs, **name_RESIDUAL_raiser):
|
|
154
154
|
'''New L{Fpowers} sum of (the I{power} of) several bases.
|
|
155
155
|
|
|
156
|
-
@arg power: The exponent (C{scalar}
|
|
157
|
-
@arg xs: One or more bases (each C{scalar}
|
|
158
|
-
|
|
156
|
+
@arg power: The exponent (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
157
|
+
@arg xs: One or more bases (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}), all
|
|
158
|
+
positional.
|
|
159
159
|
@kwarg name_RESIDUAL_raiser: Optional C{B{name}=NN} (C{str}), the C{B{RESIDUAL}=0.0}
|
|
160
160
|
threshold (C{scalar}) and C{B{raiser}=True} (C{bool}) for raising
|
|
161
161
|
L{ResidualError}s, see class L{Fsum<Fsum.__init__>} and method
|
|
@@ -175,9 +175,9 @@ class Froot(Fsum):
|
|
|
175
175
|
def __init__(self, root, *xs, **name_RESIDUAL_raiser):
|
|
176
176
|
'''New L{Froot} root of a precision sum.
|
|
177
177
|
|
|
178
|
-
@arg root: The order (C{scalar}
|
|
179
|
-
@arg xs: Items to summate (each a C{scalar}
|
|
180
|
-
|
|
178
|
+
@arg root: The order (C{scalar}, an L{Fsum} or L{Fsum2Tuple}), non-zero.
|
|
179
|
+
@arg xs: Items to summate (each a C{scalar}, an L{Fsum} or L{Fsum2Tuple}), all
|
|
180
|
+
positional.
|
|
181
181
|
@kwarg name_RESIDUAL_raiser: Optional C{B{name}=NN} (C{str}), the C{B{RESIDUAL}=0.0}
|
|
182
182
|
threshold (C{scalar}) and C{B{raiser}=True} (C{bool}) for raising
|
|
183
183
|
L{ResidualError}s, see class L{Fsum<Fsum.__init__>} and method
|
|
@@ -226,7 +226,7 @@ def bqrt(x):
|
|
|
226
226
|
'''Return the 4-th, I{bi-quadratic} or I{quartic} root, M{x**(1 / 4)},
|
|
227
227
|
preserving C{type(B{x})}.
|
|
228
228
|
|
|
229
|
-
@arg x: Value (C{scalar}
|
|
229
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
230
230
|
|
|
231
231
|
@return: I{Quartic} root (C{float} or an L{Fsum}).
|
|
232
232
|
|
|
@@ -256,7 +256,7 @@ except ImportError: # Python 3.10-
|
|
|
256
256
|
def cbrt(x):
|
|
257
257
|
'''Compute the cube root M{x**(1/3)}, preserving C{type(B{x})}.
|
|
258
258
|
|
|
259
|
-
@arg x: Value (C{scalar}
|
|
259
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
260
260
|
|
|
261
261
|
@return: Cubic root (C{float} or L{Fsum}).
|
|
262
262
|
|
|
@@ -274,7 +274,7 @@ def cbrt(x):
|
|
|
274
274
|
def cbrt2(x): # PYCHOK attr
|
|
275
275
|
'''Compute the cube root I{squared} M{x**(2/3)}, preserving C{type(B{x})}.
|
|
276
276
|
|
|
277
|
-
@arg x: Value (C{scalar}
|
|
277
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
278
278
|
|
|
279
279
|
@return: Cube root I{squared} (C{float} or L{Fsum}).
|
|
280
280
|
|
|
@@ -284,11 +284,11 @@ def cbrt2(x): # PYCHOK attr
|
|
|
284
284
|
|
|
285
285
|
|
|
286
286
|
def euclid(x, y):
|
|
287
|
-
'''I{Appoximate} the norm M{sqrt(x**2 + y**2)} by
|
|
288
|
-
|
|
287
|
+
'''I{Appoximate} the norm M{sqrt(x**2 + y**2)} by M{max(abs(x),
|
|
288
|
+
abs(y)) + min(abs(x), abs(y)) * 0.4142...}.
|
|
289
289
|
|
|
290
|
-
@arg x: X component (C{scalar}
|
|
291
|
-
@arg y: Y component (C{scalar}
|
|
290
|
+
@arg x: X component (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
291
|
+
@arg y: Y component (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
292
292
|
|
|
293
293
|
@return: Appoximate norm (C{float} or L{Fsum}).
|
|
294
294
|
|
|
@@ -301,11 +301,11 @@ def euclid(x, y):
|
|
|
301
301
|
|
|
302
302
|
|
|
303
303
|
def euclid_(*xs):
|
|
304
|
-
'''I{Appoximate} the norm M{sqrt(sum(x**2 for x in xs))} by
|
|
305
|
-
|
|
304
|
+
'''I{Appoximate} the norm M{sqrt(sum(x**2 for x in xs))} by cascaded
|
|
305
|
+
L{euclid}.
|
|
306
306
|
|
|
307
|
-
@arg xs: X arguments (each C{scalar}
|
|
308
|
-
|
|
307
|
+
@arg xs: X arguments (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}),
|
|
308
|
+
all positional.
|
|
309
309
|
|
|
310
310
|
@return: Appoximate norm (C{float} or L{Fsum}).
|
|
311
311
|
|
|
@@ -404,10 +404,10 @@ def fatan2(y, x):
|
|
|
404
404
|
|
|
405
405
|
|
|
406
406
|
def favg(a, b, f=_0_5):
|
|
407
|
-
'''Return the
|
|
407
|
+
'''Return the precise average of two values.
|
|
408
408
|
|
|
409
|
-
@arg a: One (C{scalar}
|
|
410
|
-
@arg b: Other (C{scalar}
|
|
409
|
+
@arg a: One (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
410
|
+
@arg b: Other (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
411
411
|
@kwarg f: Optional fraction (C{float}).
|
|
412
412
|
|
|
413
413
|
@return: M{a + f * (b - a)} (C{float}).
|
|
@@ -421,11 +421,11 @@ def favg(a, b, f=_0_5):
|
|
|
421
421
|
|
|
422
422
|
|
|
423
423
|
def fdot(a, *b):
|
|
424
|
-
'''Return the precision dot product M{sum(a[i] * b[i] for
|
|
425
|
-
i=0..len(a))}.
|
|
424
|
+
'''Return the precision dot product M{sum(a[i] * b[i] for ni=0..len(a))}.
|
|
426
425
|
|
|
427
|
-
@arg a: Iterable of values (each C{scalar}).
|
|
428
|
-
@arg b: Other values (each C{scalar}), all
|
|
426
|
+
@arg a: Iterable of values (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
427
|
+
@arg b: Other values (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}), all
|
|
428
|
+
positional.
|
|
429
429
|
|
|
430
430
|
@return: Dot product (C{float}).
|
|
431
431
|
|
|
@@ -438,22 +438,17 @@ def fdot(a, *b):
|
|
|
438
438
|
|
|
439
439
|
|
|
440
440
|
def fdot3(xs, ys, zs, start=0):
|
|
441
|
-
'''Return the precision dot product M{start +
|
|
442
|
-
|
|
443
|
-
|
|
444
|
-
@arg xs: Iterable (each C{scalar}
|
|
445
|
-
|
|
446
|
-
@arg
|
|
447
|
-
|
|
448
|
-
@arg zs: Iterable (each C{scalar} or an L{Fsum} or
|
|
449
|
-
L{Fsum2Tuple} instance).
|
|
450
|
-
@kwarg start: Optional bias (C{scalar} or an L{Fsum}
|
|
451
|
-
or L{Fsum2Tuple}).
|
|
441
|
+
'''Return the precision dot product M{start + sum(a[i] * b[i] * c[i]
|
|
442
|
+
for i=0..len(a)-1)}.
|
|
443
|
+
|
|
444
|
+
@arg xs: Iterable (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
445
|
+
@arg ys: Iterable (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
446
|
+
@arg zs: Iterable (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
447
|
+
@kwarg start: Optional bias (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
452
448
|
|
|
453
449
|
@return: Dot product (C{float}).
|
|
454
450
|
|
|
455
|
-
@raise LenError: Unequal C{len(B{xs})}, C{len(B{ys})}
|
|
456
|
-
and/or C{len(B{zs})}.
|
|
451
|
+
@raise LenError: Unequal C{len(B{xs})}, C{len(B{ys})} and/or C{len(B{zs})}.
|
|
457
452
|
|
|
458
453
|
@raise OverflowError: Partial C{2sum} overflow.
|
|
459
454
|
'''
|
|
@@ -462,9 +457,8 @@ def fdot3(xs, ys, zs, start=0):
|
|
|
462
457
|
yield s
|
|
463
458
|
if p:
|
|
464
459
|
yield _1_0
|
|
465
|
-
_F = Fsum
|
|
466
460
|
for x, y, z in zip(xs, ys, zs):
|
|
467
|
-
yield (
|
|
461
|
+
yield (Fsum(x) * y) * z
|
|
468
462
|
if p:
|
|
469
463
|
yield _N_1_0
|
|
470
464
|
|
|
@@ -475,15 +469,16 @@ def fdot3(xs, ys, zs, start=0):
|
|
|
475
469
|
return fsum(_mul3(xs, ys, zs, start, n < 4))
|
|
476
470
|
|
|
477
471
|
|
|
478
|
-
def fhorner(x, *cs):
|
|
479
|
-
'''Evaluate
|
|
480
|
-
i=0..
|
|
472
|
+
def fhorner(x, *cs, **incx):
|
|
473
|
+
'''Evaluate a polynomial using the Horner form M{sum(cs[i] * x**i
|
|
474
|
+
for i=0..n)} or if C{B{incx}=False} for decreasing exponent
|
|
475
|
+
M{sum(... i=n..0)} where C{n = len(cs) - 1}.
|
|
481
476
|
|
|
482
477
|
@return: Horner sum (C{float}).
|
|
483
478
|
|
|
484
479
|
@see: Class L{Fhorner} for further details.
|
|
485
480
|
'''
|
|
486
|
-
H = Fhorner(x, *cs)
|
|
481
|
+
H = Fhorner(x, *cs, **incx)
|
|
487
482
|
return float(H)
|
|
488
483
|
|
|
489
484
|
|
|
@@ -491,10 +486,9 @@ def fidw(xs, ds, beta=2):
|
|
|
491
486
|
'''Interpolate using U{Inverse Distance Weighting
|
|
492
487
|
<https://WikiPedia.org/wiki/Inverse_distance_weighting>} (IDW).
|
|
493
488
|
|
|
494
|
-
@arg xs: Known values (each C{scalar}
|
|
495
|
-
|
|
496
|
-
|
|
497
|
-
or L{Fsum2Tuple} instance).
|
|
489
|
+
@arg xs: Known values (each C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
490
|
+
@arg ds: Non-negative distances (each C{scalar}, an L{Fsum} or
|
|
491
|
+
L{Fsum2Tuple}).
|
|
498
492
|
@kwarg beta: Inverse distance power (C{int}, 0, 1, 2, or 3).
|
|
499
493
|
|
|
500
494
|
@return: Interpolated value C{x} (C{float}).
|
|
@@ -550,10 +544,22 @@ def fidw(xs, ds, beta=2):
|
|
|
550
544
|
return x
|
|
551
545
|
|
|
552
546
|
|
|
547
|
+
def fma(x, y, z):
|
|
548
|
+
'''Fused-multiply-add, as C{math.fma(x, y, z)} from Python 3.13+.
|
|
549
|
+
|
|
550
|
+
@arg x: A C{scalar}, an L{Fsum} or L{Fsum2Tuple} instance.
|
|
551
|
+
@arg y: A C{scalar}, an L{Fsum} or L{Fsum2Tuple} instance.
|
|
552
|
+
@arg z: A C{scalar}, an L{Fsum} or L{Fsum2Tuple} instance.
|
|
553
|
+
|
|
554
|
+
@return: C{(x * y) + z} (C{float} or an L{Fsum}).
|
|
555
|
+
'''
|
|
556
|
+
return Fsum(x).fma(y, z).as_iscalar
|
|
557
|
+
|
|
558
|
+
|
|
553
559
|
def fmean(xs):
|
|
554
560
|
'''Compute the accurate mean M{sum(xs) / len(xs)}.
|
|
555
561
|
|
|
556
|
-
@arg xs: Values (C{scalar} or L{Fsum}
|
|
562
|
+
@arg xs: Values (each C{scalar}, or L{Fsum} or L{Fsum2Tuple}).
|
|
557
563
|
|
|
558
564
|
@return: Mean value (C{float}).
|
|
559
565
|
|
|
@@ -576,8 +582,8 @@ def fmean_(*xs):
|
|
|
576
582
|
|
|
577
583
|
|
|
578
584
|
def fpolynomial(x, *cs, **over):
|
|
579
|
-
'''Evaluate the polynomial M{sum(cs[i] * x**i for
|
|
580
|
-
|
|
585
|
+
'''Evaluate the polynomial M{sum(cs[i] * x**i for i=0..len(cs))
|
|
586
|
+
[/ over]}.
|
|
581
587
|
|
|
582
588
|
@kwarg over: Optional final, I{non-zero} divisor (C{scalar}).
|
|
583
589
|
|
|
@@ -593,7 +599,7 @@ def fpolynomial(x, *cs, **over):
|
|
|
593
599
|
def fpowers(x, n, alts=0):
|
|
594
600
|
'''Return a series of powers M{[x**i for i=1..n]}.
|
|
595
601
|
|
|
596
|
-
@arg x: Value (C{scalar}
|
|
602
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
597
603
|
@arg n: Highest exponent (C{int}).
|
|
598
604
|
@kwarg alts: Only alternating powers, starting with this
|
|
599
605
|
exponent (C{int}).
|
|
@@ -627,7 +633,7 @@ except ImportError:
|
|
|
627
633
|
'''Iterable product, like C{math.prod} or C{numpy.prod}.
|
|
628
634
|
|
|
629
635
|
@arg xs: Iterable of values to be multiplied (each
|
|
630
|
-
C{scalar}
|
|
636
|
+
C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
631
637
|
@kwarg start: Initial value, also the value returned
|
|
632
638
|
for an empty B{C{xs}} (C{scalar}).
|
|
633
639
|
|
|
@@ -822,8 +828,8 @@ def hypot1(x):
|
|
|
822
828
|
def hypot2(x, y):
|
|
823
829
|
'''Compute the I{squared} norm M{x**2 + y**2}.
|
|
824
830
|
|
|
825
|
-
@arg x: X (C{scalar}
|
|
826
|
-
@arg y: Y (C{scalar}
|
|
831
|
+
@arg x: X (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
832
|
+
@arg y: Y (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
827
833
|
|
|
828
834
|
@return: C{B{x}**2 + B{y}**2} (C{float}).
|
|
829
835
|
'''
|
|
@@ -843,8 +849,8 @@ def hypot2(x, y):
|
|
|
843
849
|
def hypot2_(*xs):
|
|
844
850
|
'''Compute the I{squared} norm C{fsum(x**2 for x in B{xs})}.
|
|
845
851
|
|
|
846
|
-
@arg xs: Components (each C{scalar}
|
|
847
|
-
L{Fsum2Tuple}
|
|
852
|
+
@arg xs: Components (each C{scalar}, an L{Fsum} or
|
|
853
|
+
L{Fsum2Tuple}), all positional.
|
|
848
854
|
|
|
849
855
|
@return: Squared norm (C{float}).
|
|
850
856
|
|
|
@@ -886,6 +892,7 @@ def norm2(x, y):
|
|
|
886
892
|
or zero norm.
|
|
887
893
|
'''
|
|
888
894
|
try:
|
|
895
|
+
h = None
|
|
889
896
|
h = hypot(x, y)
|
|
890
897
|
if h:
|
|
891
898
|
x, y = (x / h), (y / h)
|
|
@@ -898,9 +905,10 @@ def norm2(x, y):
|
|
|
898
905
|
|
|
899
906
|
|
|
900
907
|
def norm_(*xs):
|
|
901
|
-
'''Normalize
|
|
908
|
+
'''Normalize the components of an n-dimensional vector.
|
|
902
909
|
|
|
903
|
-
@arg xs: Components (C{scalar}
|
|
910
|
+
@arg xs: Components (each C{scalar}, an L{Fsum} or
|
|
911
|
+
L{Fsum2Tuple}), all positional.
|
|
904
912
|
|
|
905
913
|
@return: Yield each component, normalized.
|
|
906
914
|
|
|
@@ -943,7 +951,7 @@ def sqrt0(x, Error=None):
|
|
|
943
951
|
'''Return the square root C{sqrt(B{x})} iff C{B{x} > }L{EPS02},
|
|
944
952
|
preserving C{type(B{x})}.
|
|
945
953
|
|
|
946
|
-
@arg x: Value (C{scalar}
|
|
954
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
947
955
|
@kwarg Error: Error to raise for negative B{C{x}}.
|
|
948
956
|
|
|
949
957
|
@return: Square root (C{float} or L{Fsum}) or C{0.0}.
|
|
@@ -955,14 +963,15 @@ def sqrt0(x, Error=None):
|
|
|
955
963
|
'''
|
|
956
964
|
if Error and x < 0:
|
|
957
965
|
raise Error(unstr(sqrt0, x))
|
|
958
|
-
return _root(x, _0_5, sqrt0) if x > EPS02 else (
|
|
966
|
+
return _root(x, _0_5, sqrt0) if x > EPS02 else (
|
|
967
|
+
_0_0 if x < EPS02 else EPS0)
|
|
959
968
|
|
|
960
969
|
|
|
961
970
|
def sqrt3(x):
|
|
962
971
|
'''Return the square root, I{cubed} M{sqrt(x)**3} or M{sqrt(x**3)},
|
|
963
972
|
preserving C{type(B{x})}.
|
|
964
973
|
|
|
965
|
-
@arg x: Value (C{scalar}
|
|
974
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
966
975
|
|
|
967
976
|
@return: Square root I{cubed} (C{float} or L{Fsum}).
|
|
968
977
|
|
|
@@ -1018,7 +1027,7 @@ def zcrt(x):
|
|
|
1018
1027
|
'''Return the 6-th, I{zenzi-cubic} root, M{x**(1 / 6)},
|
|
1019
1028
|
preserving C{type(B{x})}.
|
|
1020
1029
|
|
|
1021
|
-
@arg x: Value (C{scalar}
|
|
1030
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
1022
1031
|
|
|
1023
1032
|
@return: I{Zenzi-cubic} root (C{float} or L{Fsum}).
|
|
1024
1033
|
|
|
@@ -1035,7 +1044,7 @@ def zqrt(x):
|
|
|
1035
1044
|
'''Return the 8-th, I{zenzi-quartic} or I{squared-quartic} root,
|
|
1036
1045
|
M{x**(1 / 8)}, preserving C{type(B{x})}.
|
|
1037
1046
|
|
|
1038
|
-
@arg x: Value (C{scalar}
|
|
1047
|
+
@arg x: Value (C{scalar}, an L{Fsum} or L{Fsum2Tuple}).
|
|
1039
1048
|
|
|
1040
1049
|
@return: I{Zenzi-quartic} root (C{float} or L{Fsum}).
|
|
1041
1050
|
|