dpnp.linalg.cond

dpnp.linalg.cond(x, p=None)[source]

Compute the condition number of a matrix.

For full documentation refer to numpy.linalg.cond.

Parameters:
  • x ({dpnp.ndarray, usm_ndarray}) -- The matrix whose condition number is sought.

  • p ({None, 1, -1, 2, -2, inf, -inf, "fro"}, optional) -- Order of the norm used in the condition number computation. inf means the dpnp.inf object, and the Frobenius norm is the root-of-sum-of-squares norm. Default: None.

Returns:

out -- The condition number of the matrix. May be infinite.

Return type:

dpnp.ndarray

See also

dpnp.linalg.norm

Matrix or vector norm.

Examples

>>> import dpnp 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)
array(1.41421356)
>>> np.linalg.cond(a, 'fro')
array(3.16227766)
>>> np.linalg.cond(a, np.inf)
array(2.)
>>> np.linalg.cond(a, -np.inf)
array(1.)
>>> np.linalg.cond(a, 1)
array(2.)
>>> np.linalg.cond(a, -1)
array(1.)
>>> np.linalg.cond(a, 2)
array(1.41421356)
>>> np.linalg.cond(a, -2)
array(0.70710678) # may vary
>>> x = min(np.linalg.svd(a, compute_uv=False))
>>> y = min(np.linalg.svd(np.linalg.inv(a), compute_uv=False))
>>> x * y
array(0.70710678) # may vary