This is a pre-release version (latest).Go to latest (2.4.4)
{ } Raw JSON

bundles / numpy latest / numpy / polynomial / polyutils / mapdomain

function

numpy.polynomial.polyutils:mapdomain

source: build-install/usr/lib/python3.14/site-packages/numpy/polynomial/polyutils.py:288

Signature

def mapdomain(x, old, new)

Summary

Apply linear map to input points.

Extended Summary

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

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.

Notes

Effectively, this implements:

where

Examples

import numpy as np
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.2566, 2.5133, 3.7699, 5.0265, 6.2832])
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. +1.j , -0.6+0.6j, -0.2+0.2j,  0.2-0.2j,  0.6-0.6j,  1. -1.j ])

See also

getdomain
mapparms

Aliases

  • numpy.polynomial.polyutils.mapdomain