pygeodesy 24.4.12__py2.py3-none-any.whl → 24.4.18__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.4.12.dist-info → PyGeodesy-24.4.18.dist-info}/METADATA +2 -2
- {PyGeodesy-24.4.12.dist-info → PyGeodesy-24.4.18.dist-info}/RECORD +20 -20
- pygeodesy/__init__.py +1 -1
- pygeodesy/albers.py +12 -19
- pygeodesy/auxilats/auxLat.py +3 -3
- pygeodesy/deprecated/__init__.py +1 -1
- pygeodesy/deprecated/classes.py +14 -1
- pygeodesy/ellipsoids.py +3 -3
- pygeodesy/elliptic.py +10 -11
- pygeodesy/errors.py +27 -28
- pygeodesy/fmath.py +64 -65
- pygeodesy/fsums.py +290 -215
- pygeodesy/lazily.py +3 -3
- pygeodesy/ltp.py +11 -11
- pygeodesy/osgr.py +24 -24
- pygeodesy/resections.py +16 -24
- pygeodesy/triaxials.py +4 -4
- pygeodesy/vector2d.py +9 -8
- {PyGeodesy-24.4.12.dist-info → PyGeodesy-24.4.18.dist-info}/WHEEL +0 -0
- {PyGeodesy-24.4.12.dist-info → PyGeodesy-24.4.18.dist-info}/top_level.txt +0 -0
pygeodesy/fmath.py
CHANGED
|
@@ -13,8 +13,8 @@ from pygeodesy.constants import EPS0, EPS02, EPS1, NAN, PI, PI_2, PI_4, \
|
|
|
13
13
|
_copysign_0_0, _isfinite, _over, remainder
|
|
14
14
|
from pygeodesy.errors import _IsnotError, LenError, _TypeError, _ValueError, \
|
|
15
15
|
_xError, _xkwds_get, _xkwds_pop2
|
|
16
|
-
from pygeodesy.fsums import _2float, Fsum, _fsum, fsum, fsum1_,
|
|
17
|
-
|
|
16
|
+
from pygeodesy.fsums import _2float, Fsum, _fsum, fsum, fsum1_, _1primed, \
|
|
17
|
+
Fmt, unstr
|
|
18
18
|
from pygeodesy.interns import MISSING, _few_, _h_, _invokation_, _negative_, \
|
|
19
19
|
_not_scalar_, _SPACE_, _too_
|
|
20
20
|
from pygeodesy.lazily import _ALL_LAZY, _sys_version_info2
|
|
@@ -25,13 +25,21 @@ from math import fabs, sqrt # pow
|
|
|
25
25
|
import operator as _operator # in .datums, .trf, .utm
|
|
26
26
|
|
|
27
27
|
__all__ = _ALL_LAZY.fmath
|
|
28
|
-
__version__ = '24.04.
|
|
28
|
+
__version__ = '24.04.17'
|
|
29
29
|
|
|
30
30
|
# sqrt(2) <https://WikiPedia.org/wiki/Square_root_of_2>
|
|
31
31
|
_0_4142 = 0.41421356237309504880 # ... sqrt(2) - 1
|
|
32
32
|
_h_lt_b_ = 'abs(h) < abs(b)'
|
|
33
33
|
|
|
34
34
|
|
|
35
|
+
def _Fsum__init__(inst, raiser=MISSING, **name_RESIDUAL):
|
|
36
|
+
'''(INTERNAL) Init an C{Fsum} instance.
|
|
37
|
+
'''
|
|
38
|
+
Fsum.__init__(inst, **name_RESIDUAL) # PYCHOK self
|
|
39
|
+
inst._fset_ps(_0_0)
|
|
40
|
+
return {} if raiser is MISSING else dict(raiser=raiser)
|
|
41
|
+
|
|
42
|
+
|
|
35
43
|
class Fdot(Fsum):
|
|
36
44
|
'''Precision dot product.
|
|
37
45
|
'''
|
|
@@ -41,8 +49,8 @@ class Fdot(Fsum):
|
|
|
41
49
|
|
|
42
50
|
@arg a: Iterable, list, tuple, etc. (C{scalar}s).
|
|
43
51
|
@arg b: Other values (C{scalar}s), all positional.
|
|
44
|
-
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and
|
|
45
|
-
|
|
52
|
+
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and C{B{RESIDUAL}=None},
|
|
53
|
+
see L{Fsum<Fsum.__init__>}.
|
|
46
54
|
|
|
47
55
|
@raise OverflowError: Partial C{2sum} overflow.
|
|
48
56
|
|
|
@@ -64,8 +72,8 @@ class Fhorner(Fsum):
|
|
|
64
72
|
@arg x: Polynomial argument (C{scalar} or C{Fsum} instance).
|
|
65
73
|
@arg cs: Polynomial coeffients (C{scalar} or C{Fsum}
|
|
66
74
|
instances), all positional.
|
|
67
|
-
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and
|
|
68
|
-
|
|
75
|
+
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and C{B{RESIDUAL}=None},
|
|
76
|
+
see L{Fsum<Fsum.__init__>}.
|
|
69
77
|
|
|
70
78
|
@raise OverflowError: Partial C{2sum} overflow.
|
|
71
79
|
|
|
@@ -92,32 +100,30 @@ class Fhorner(Fsum):
|
|
|
92
100
|
else: # x == 0
|
|
93
101
|
self._fadd(cs[0], op)
|
|
94
102
|
else:
|
|
95
|
-
self.
|
|
103
|
+
self._fset_ps(_0_0)
|
|
96
104
|
|
|
97
105
|
|
|
98
106
|
class Fhypot(Fsum):
|
|
99
107
|
'''Precision summation and hypotenuse, default C{power=2}.
|
|
100
108
|
'''
|
|
101
|
-
def __init__(self, *xs, **
|
|
102
|
-
'''New L{Fhypot} hypotenuse of (the I{
|
|
109
|
+
def __init__(self, *xs, **root_name_RESIDUAL_raiser):
|
|
110
|
+
'''New L{Fhypot} hypotenuse of (the I{root} of) several components.
|
|
103
111
|
|
|
104
|
-
@arg xs: One or more components (each a C{scalar} or an C{Fsum}
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
C{B{RESIDUAL}=None}, see L{Fsum.__init__}.
|
|
112
|
+
@arg xs: One or more components (each a C{scalar} or an C{Fsum} instance).
|
|
113
|
+
@kwarg root_name_RESIDUAL_raiser: Optional, exponent and C{B{root}=2} order,
|
|
114
|
+
C{B{name}=NN}, C{B{RESIDUAL}=None} and C{B{raiser}=True}, see
|
|
115
|
+
class L{Fsum<Fsum.__init__>} and method L{root<Fsum.root>}.
|
|
109
116
|
'''
|
|
117
|
+
r = None # _xkwds_pop2 error
|
|
110
118
|
try:
|
|
111
|
-
|
|
112
|
-
|
|
119
|
+
r, kwds = _xkwds_pop2(root_name_RESIDUAL_raiser, root=2)
|
|
120
|
+
r, kwds = _xkwds_pop2(kwds, power=r) # for backward compatibility
|
|
121
|
+
raiser = _Fsum__init__(self, **kwds)
|
|
113
122
|
if xs:
|
|
114
|
-
r
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
self._fset(_0_0)
|
|
119
|
-
except Exception as x:
|
|
120
|
-
raise self._ErrorXs(x, xs, power=p)
|
|
123
|
+
self._facc_power(r, xs, Fhypot, **raiser)
|
|
124
|
+
self._fset(self.root(r, **raiser))
|
|
125
|
+
except Exception as X:
|
|
126
|
+
raise self._ErrorXs(X, xs, root=r)
|
|
121
127
|
|
|
122
128
|
|
|
123
129
|
class Fpolynomial(Fsum):
|
|
@@ -128,10 +134,10 @@ class Fpolynomial(Fsum):
|
|
|
128
134
|
M{sum(cs[i] * x**i for i=0..len(cs)-1)}.
|
|
129
135
|
|
|
130
136
|
@arg x: Polynomial argument (C{scalar} or L{Fsum}).
|
|
131
|
-
@arg cs: Polynomial coeffients (each a C{scalar} or
|
|
132
|
-
|
|
133
|
-
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and
|
|
134
|
-
|
|
137
|
+
@arg cs: Polynomial coeffients (each a C{scalar} or an L{Fsum} instance),
|
|
138
|
+
all positional.
|
|
139
|
+
@kwarg name_RESIDUAL: Optional C{B{name}=NN} and C{B{RESIDUAL}=None},
|
|
140
|
+
see L{Fsum<Fsum.__init__>}.
|
|
135
141
|
|
|
136
142
|
@raise OverflowError: Partial C{2sum} overflow.
|
|
137
143
|
|
|
@@ -147,75 +153,68 @@ class Fpolynomial(Fsum):
|
|
|
147
153
|
if n > 0:
|
|
148
154
|
self.fadd(_1map_mul(cs[1:], _powers(x, n)))
|
|
149
155
|
elif n < 0:
|
|
150
|
-
self.
|
|
156
|
+
self._fset_ps(_0_0)
|
|
151
157
|
|
|
152
158
|
|
|
153
159
|
class Fpowers(Fsum):
|
|
154
160
|
'''Precision summation of powers, optimized for C{power=2, 3 and 4}.
|
|
155
161
|
'''
|
|
156
|
-
def __init__(self, power, *xs, **
|
|
162
|
+
def __init__(self, power, *xs, **name_RESIDUAL_raiser):
|
|
157
163
|
'''New L{Fpowers} sum of (the I{power} of) several values.
|
|
158
164
|
|
|
159
165
|
@arg power: The exponent (C{scalar} or L{Fsum}).
|
|
160
|
-
@arg xs: One or more values (each a C{scalar} or an
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
C{B{RESIDUAL}=None}, see L{Fsum.__init__}.
|
|
166
|
+
@arg xs: One or more values (each a C{scalar} or an C{Fsum} instance).
|
|
167
|
+
@kwarg name_RESIDUAL_raiser: Optional C{B{name}=NN}, C{B{RESIDUAL}=None} and
|
|
168
|
+
C{B{raiser}=True}, see L{Fsum<Fsum.__init__>} and L{fpow<Fsum.fpow>}.
|
|
164
169
|
'''
|
|
165
170
|
try:
|
|
166
|
-
|
|
171
|
+
raiser = _Fsum__init__(self, **name_RESIDUAL_raiser)
|
|
167
172
|
if xs:
|
|
168
|
-
self._facc_power(power, xs, Fpowers) # x**0 == 1
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
except Exception as x:
|
|
172
|
-
raise self._ErrorXs(x, xs, power=power)
|
|
173
|
+
self._facc_power(power, xs, Fpowers, **raiser) # x**0 == 1
|
|
174
|
+
except Exception as X:
|
|
175
|
+
raise self._ErrorXs(X, xs, power=power)
|
|
173
176
|
|
|
174
177
|
|
|
175
|
-
class
|
|
176
|
-
'''
|
|
178
|
+
class Froot(Fsum):
|
|
179
|
+
'''The root of a precision summation.
|
|
177
180
|
'''
|
|
178
|
-
def __init__(self, root, *xs, **
|
|
179
|
-
'''New L{
|
|
181
|
+
def __init__(self, root, *xs, **name_RESIDUAL_raiser):
|
|
182
|
+
'''New L{Froot} root of a precision sum.
|
|
180
183
|
|
|
181
|
-
@arg root: The order (C{scalar} or C{Fsum}),
|
|
182
|
-
|
|
183
|
-
@
|
|
184
|
-
|
|
185
|
-
@kwarg name_RESIDUAL: See L{Fsum.__init__}.
|
|
184
|
+
@arg root: The order (C{scalar} or C{Fsum}), non-zero.
|
|
185
|
+
@arg xs: Values to summate (each a C{scalar} or an C{Fsum} instance).
|
|
186
|
+
@kwarg name_RESIDUAL_raiser: Optional C{B{name}=NN}, C{B{RESIDUAL}=None} and
|
|
187
|
+
C{B{raiser}=True}, see L{Fsum<Fsum.__init__>} and L{fpow<Fsum.fpow>}.
|
|
186
188
|
'''
|
|
187
189
|
try:
|
|
188
|
-
|
|
190
|
+
raiser = _Fsum__init__(self, **name_RESIDUAL_raiser)
|
|
189
191
|
if xs:
|
|
190
|
-
r = _1_0 / root
|
|
191
192
|
self. fadd(xs)
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
except Exception as x:
|
|
196
|
-
raise self._ErrorXs(x, xs, root=root)
|
|
193
|
+
self._fset(self.root(root, **raiser))
|
|
194
|
+
except Exception as X:
|
|
195
|
+
raise self._ErrorXs(X, xs, root=root)
|
|
197
196
|
|
|
198
197
|
|
|
199
|
-
class Fcbrt(
|
|
198
|
+
class Fcbrt(Froot):
|
|
200
199
|
'''Cubic root of a precision summation.
|
|
201
200
|
'''
|
|
202
|
-
def __init__(self, *xs, **
|
|
201
|
+
def __init__(self, *xs, **name_RESIDUAL_raiser):
|
|
203
202
|
'''New L{Fcbrt} cubic root of a precision sum.
|
|
204
203
|
|
|
205
|
-
@see: Class L{
|
|
204
|
+
@see: Class L{Froot} for further details.
|
|
206
205
|
'''
|
|
207
|
-
|
|
206
|
+
Froot.__init__(self, _3_0, *xs, **name_RESIDUAL_raiser)
|
|
208
207
|
|
|
209
208
|
|
|
210
|
-
class Fsqrt(
|
|
209
|
+
class Fsqrt(Froot):
|
|
211
210
|
'''Square root of a precision summation.
|
|
212
211
|
'''
|
|
213
|
-
def __init__(self, *xs, **
|
|
212
|
+
def __init__(self, *xs, **name_RESIDUAL_raiser):
|
|
214
213
|
'''New L{Fsqrt} square root of a precision sum.
|
|
215
214
|
|
|
216
|
-
@see: Class L{
|
|
215
|
+
@see: Class L{Froot} for further details.
|
|
217
216
|
'''
|
|
218
|
-
|
|
217
|
+
Froot.__init__(self, _2_0, *xs, **name_RESIDUAL_raiser)
|
|
219
218
|
|
|
220
219
|
|
|
221
220
|
def bqrt(x):
|
|
@@ -818,7 +817,7 @@ def _map_mul(a, b, where):
|
|
|
818
817
|
n = len(b)
|
|
819
818
|
if len(a) != n: # PYCHOK no cover
|
|
820
819
|
raise LenError(where, a=len(a), b=n)
|
|
821
|
-
return
|
|
820
|
+
return _1map_mul(a, b) if n < 4 else map(_operator.mul, a, b)
|
|
822
821
|
|
|
823
822
|
|
|
824
823
|
def _1map_mul(a, b):
|