This is a pre-release version (2.0.0.dev0+git20260907.41eeb59).Go to latest (1.18.0)
{ } Raw JSON

bundles / scipy 2.0.0.dev0+git20260907.41eeb59 / scipy / linalg / _decomp_svd / null_space

function

scipy.linalg._decomp_svd:null_space

source: build-install/usr/lib/python3.14/site-packages/scipy/linalg/_decomp_svd.py:411

Signature

def null_space(A, rcond = None, *, overwrite_a = False, check_finite = True, lapack_driver = gesdd)

Summary

Construct an orthonormal basis for the null space of A using SVD.

Extended Summary

The documentation is written assuming array arguments are of specified "core" shapes. However, array argument(s) of this function may have additional "batch" dimensions prepended to the core shape. In this case, the array is treated as a batch of lower-dimensional slices; see linalg_batch for details. The NEP 5 signature of this function is (m,n)->(n,n).

Parameters

A : (M, N) array_like

Input array

rcond : float, optional

Relative condition number. Singular values s smaller than rcond * max(s) are considered zero. Default: floating point eps * max(M,N).

overwrite_a : bool, optional

Whether to overwrite a; may improve performance. Default is False. See tutorial_linalg_overwrite for details.

check_finite : bool, optional

Whether to check that the input matrix contains only finite numbers. Disabling may give a performance gain, but may result in problems (crashes, non-termination) if the inputs do contain infinities or NaNs.

lapack_driver : {'gesdd', 'gesvd'}, optional

Whether to use the more efficient divide-and-conquer approach ('gesdd') or general rectangular approach ('gesvd') to compute the SVD. MATLAB and Octave use the 'gesvd' approach. Default is 'gesdd'.

Returns

Z : (N, K) ndarray

Orthonormal basis for the null space of A. K = dimension of effective null space, as determined by rcond

Examples

1-D null space:
import numpy as np
from scipy.linalg import null_space
A = np.array([[1, 1], [1, 1]])
ns = null_space(A)
✓
ns * np.copysign(1, ns[0,0])  # Remove the sign ambiguity of the vector
✗
array([[ 0.71],
       [-0.71]])
2-D null space:
from numpy.random import default_rng
rng = default_rng()
B = rng.random((3, 5))
Z = null_space(B)
Z.shape
np.allclose(B.dot(Z), 0)
✓
True
The basis vectors are orthonormal (up to rounding error):
Z.T.dot(Z)
✗
array([[1., 0.],
       [0., 1.]])

See also

orth

Matrix range

svd

Singular value decomposition of a matrix

Aliases

  • scipy.linalg.null_space

Referenced by