polar(a, side='right')
Returns the factors of the polar decomposition u
and p
such that a = up
(if :None:None:`side`
is "right") or a = pu
(if :None:None:`side`
is "left"), where p
is positive semidefinite. Depending on the shape of a
, either the rows or columns of u
are orthonormal. When a
is a square array, u
is a square unitary array. When a
is not square, the "canonical polar decomposition" is computed.
The array to be factored.
Determines whether a right or left polar decomposition is computed. If :None:None:`side`
is "right", then a = up
. If :None:None:`side`
is "left", then a = pu
. The default is "right".
If a
is square, then u
is unitary. If m > n, then the columns of a
are orthonormal, and if m < n, then the rows of u
are orthonormal.
p
is Hermitian positive semidefinite. If a
is nonsingular, p
is positive definite. The shape of p
is (n, n) or (m, m), depending on whether :None:None:`side`
is "right" or "left", respectively.
Compute the polar decomposition.
>>> from scipy.linalg import polar
... a = np.array([[1, -1], [2, 4]])
... u, p = polar(a)
... u array([[ 0.85749293, -0.51449576], [ 0.51449576, 0.85749293]])
>>> p array([[ 1.88648444, 1.2004901 ], [ 1.2004901 , 3.94446746]])
A non-square example, with m < n:
>>> b = np.array([[0.5, 1, 2], [1.5, 3, 4]])
... u, p = polar(b)
... u array([[-0.21196618, -0.42393237, 0.88054056], [ 0.39378971, 0.78757942, 0.4739708 ]])
>>> p array([[ 0.48470147, 0.96940295, 1.15122648], [ 0.96940295, 1.9388059 , 2.30245295], [ 1.15122648, 2.30245295, 3.65696431]])
>>> u.dot(p) # Verify the decomposition. array([[ 0.5, 1. , 2. ], [ 1.5, 3. , 4. ]])
>>> u.dot(u.T) # The rows of u are orthonormal. array([[ 1.00000000e+00, -2.07353665e-17], [ -2.07353665e-17, 1.00000000e+00]])
Another non-square example, with m > n:
>>> c = b.T
... u, p = polar(c)
... u array([[-0.21196618, 0.39378971], [-0.42393237, 0.78757942], [ 0.88054056, 0.4739708 ]])
>>> p array([[ 1.23116567, 1.93241587], [ 1.93241587, 4.84930602]])
>>> u.dot(p) # Verify the decomposition. array([[ 0.5, 1.5], [ 1. , 3. ], [ 2. , 4. ]])
>>> u.T.dot(u) # The columns of u are orthonormal. array([[ 1.00000000e+00, -1.26363763e-16], [ -1.26363763e-16, 1.00000000e+00]])See :
The following pages refer to to this document either explicitly or contain code examples using this.
scipy.linalg._decomp_polar.polar
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