MCPcopy Create free account
hub / github.com/numpy/numpy / mapparms

Function mapparms

numpy/polynomial/polyutils.py:260–305  ·  view source on GitHub ↗

Linear map parameters between domains. Return the parameters of the linear map ``offset + scale*x`` that maps `old` to `new` such that ``old[i] -> new[i]``, ``i = 0, 1``. Parameters ---------- old, new : array_like Domains. Each domain must (successfully) convert t

(old, new)

Source from the content-addressed store, hash-verified

258 return np.array((x.min(), x.max()))
259
260def mapparms(old, new):
261 """
262 Linear map parameters between domains.
263
264 Return the parameters of the linear map ``offset + scale*x`` that maps
265 `old` to `new` such that ``old[i] -> new[i]``, ``i = 0, 1``.
266
267 Parameters
268 ----------
269 old, new : array_like
270 Domains. Each domain must (successfully) convert to a 1-d array
271 containing precisely two values.
272
273 Returns
274 -------
275 offset, scale : scalars
276 The map ``L(x) = offset + scale*x`` maps the first domain to the
277 second.
278
279 See Also
280 --------
281 getdomain, mapdomain
282
283 Notes
284 -----
285 Also works for complex numbers, and thus can be used to calculate the
286 parameters required to map any line in the complex plane to any other
287 line therein.
288
289 Examples
290 --------
291 >>> from numpy.polynomial import polyutils as pu
292 >>> pu.mapparms((-1,1),(-1,1))
293 (0.0, 1.0)
294 >>> pu.mapparms((1,-1),(-1,1))
295 (-0.0, -1.0)
296 >>> i = complex(0,1)
297 >>> pu.mapparms((-i,-1),(1,i))
298 ((1+1j), (1-0j))
299
300 """
301 oldlen = old[1] - old[0]
302 newlen = new[1] - new[0]
303 off = (old[1]*new[0] - old[0]*new[1])/oldlen
304 scl = newlen/oldlen
305 return off, scl
306
307def mapdomain(x, old, new):
308 """

Callers 1

mapdomainFunction · 0.85

Calls

no outgoing calls

Tested by

no test coverage detected