我要评分
获取效率
正确性
完整性
易理解

linalg.cond

Description

Compute the condition number of a matrix.

This function is capable of returning the condition number using one of seven different norms, depending on the value of p For details about the norm values, see Table 1.

Mandatory Input Parameters

Parameter

Type

Description

x

(…,M,N) array_like

A matrix whose condition number is to be sought.

Optional Input Parameters

Parameter

Type

Default Value

Description

p

{None, 1, -1, 2, -2, inf, -inf, 'fro'}

None

Calculates the condition number with norms for matrices.

Return Value

Type

Description

ndarray

Condition number of the matrix.

Examples

>>> import numpy as np
>>> a = np.array([[1,0,-1], [0,1,0], [1,0,1]])
>>> a
array([[ 1,  0, -1],
       [ 0,  1,  0],
       [ 1,  0,  1]])
>>> np.linalg.cond(a)
1.4142135623730951
>>> np.linalg.cond(a, 'fro')
3.1622776601683795
>>> np.linalg.cond(a, np.inf)
2.0
>>> np.linalg.cond(a, -np.inf)
1.0
>>> np.linalg.cond(a, 1)
2.0
>>> np.linalg.cond(a, -1)
1.0
>>> np.linalg.cond(a, 2)
1.4142135623730951
>>> np.linalg.cond(a, -2)
0.7071067811865475
>>> min(np.linalg.svd(a, compute_uv=False))*min(np.linalg.svd(np.linalg.inv(a), compute_uv=False))
0.7071067811865475
>>>