numpy 1.22.4 Pypi GitHub Homepage
Other Docs
NotesParametersReturnsBackRef
mapdomain(x, old, new)

The linear map offset + scale*x that maps the domain :None:None:`old` to the domain :None:None:`new` is applied to the points x.

Notes

Effectively, this implements:

$$x\_out = new[0] + m(x - old[0])$$

where

$$m = \frac{new[1]-new[0]}{old[1]-old[0]}$$

Parameters

x : array_like

Points to be mapped. If x is a subtype of ndarray the subtype will be preserved.

old, new : array_like

The two domains that determine the map. Each must (successfully) convert to 1-d arrays containing precisely two values.

Returns

x_out : ndarray

Array of points of the same shape as x, after application of the linear map between the two domains.

Apply linear map to input points.

See Also

getdomain
mapparms

Examples

>>> from numpy.polynomial import polyutils as pu
... old_domain = (-1,1)
... new_domain = (0,2*np.pi)
... x = np.linspace(-1,1,6); x array([-1. , -0.6, -0.2, 0.2, 0.6, 1. ])
>>> x_out = pu.mapdomain(x, old_domain, new_domain); x_out
array([ 0.        ,  1.25663706,  2.51327412,  3.76991118,  5.02654825, # may vary
        6.28318531])
>>> x - pu.mapdomain(x_out, new_domain, old_domain)
array([0., 0., 0., 0., 0., 0.])

Also works for complex numbers (and thus can be used to map any line in the complex plane to any other line therein).

>>> i = complex(0,1)
... old = (-1 - i, 1 + i)
... new = (-1 + i, 1 - i)
... z = np.linspace(old[0], old[1], 6); z array([-1. -1.j , -0.6-0.6j, -0.2-0.2j, 0.2+0.2j, 0.6+0.6j, 1. +1.j ])
>>> new_z = pu.mapdomain(z, old, new); new_z
array([-1.0+1.j , -0.6+0.6j, -0.2+0.2j,  0.2-0.2j,  0.6-0.6j,  1.0-1.j ]) # may vary
See :

Back References

The following pages refer to to this document either explicitly or contain code examples using this.

numpy.polynomial.polyutils.mapparms numpy.polynomial.polyutils.getdomain

Local connectivity graph

Hover to see nodes names; edges to Self not shown, Caped at 50 nodes.

Using a canvas is more power efficient and can get hundred of nodes ; but does not allow hyperlinks; , arrows or text (beyond on hover)

SVG is more flexible but power hungry; and does not scale well to 50 + nodes.

All aboves nodes referred to, (or are referred from) current nodes; Edges from Self to other have been omitted (or all nodes would be connected to the central node "self" which is not useful). Nodes are colored by the library they belong to, and scaled with the number of references pointing them


GitHub : /numpy/polynomial/polyutils.py#303
type: <class 'function'>
Commit: