# Linalg¶

Collection of linear algebra Ivy functions.

ivy.inv(x, f=None)[source]

Computes the (multiplicative) inverse of x matrix. Given a square matrix x, returns the matrix x_inv satisfying dot(x, x_inv) = dot(x_inv, x) = eye(x.shape[0]).

Parameters
• x (array) – Matrix to be inverted.

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

(Multiplicative) inverse of the matrix x.

ivy.norm(x, ord=2, axis=- 1, keepdims=False, f=None)[source]

Matrix or vector norm. This function is able to return ord-1 and ord-2 vector-norms and matrix-norms.

Parameters
• x (array) – Input array. If axis is None, x must be 1-D or 2-D.

• ord (int) – Order of the norm.

• axis ({int, 2-sequence of ints}, optional) – If axis is an integer, it specifies the axis of x along which to compute the vector norms. If axis is a 2-tuple, it specifies the axes that hold 2-D matrices, and the matrix norms of these matrices are computed.

• keepdims (bool, optional) – If this is set to True, the axes which are normed over are left in the result as dimensions with size one. With this option the result will broadcast correctly against the original x. Default is False.

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

Norm of the matrix or vector(s).

ivy.pinv(x, f=None)[source]

Computes the pseudo inverse of x matrix.

Parameters
• x (array) – Matrix to be pseudo inverted.

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

pseudo inverse of the matrix x.

ivy.svd(x, f=None)[source]

Singular Value Decomposition. When x is a 2D array, it is factorized as u @ numpy.diag(s) @ vh = (u * s) @ vh, where u and vh are 2D unitary arrays and s is a 1D array of a’s singular values. When x is higher-dimensional, SVD is applied in batched mode.

Parameters
• x (array) – Input array with number of dimensions >= 2.

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

u -> { (…, M, M), (…, M, K) } array

Unitary array(s). The first (number of dims - 2) dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices.

s -> (…, K) array

Vector(s) with the singular values, within each vector sorted in descending ord. The first (number of dims - 2) dimensions have the same size as those of the input a.

vh -> { (…, N, N), (…, K, N) } array

Unitary array(s). The first (number of dims - 2) dimensions have the same size as those of the input a. The size of the last two dimensions depends on the value of full_matrices.

ivy.vector_to_skew_symmetric_matrix(vector, f=None)[source]

Given vector $$\mathbf{a}\in\mathbb{R}^3$$, return associated skew-symmetric matrix $$[\mathbf{a}]_×\in\mathbb{R}^{3×3}$$ satisfying $$\mathbf{a}×\mathbf{b}=[\mathbf{a}]_×\mathbf{b}$$.

[reference]

Parameters
• vector (array) – Vector to convert [batch_shape,3].

• f (ml_framework, optional) – Machine learning framework. Inferred from inputs if None.

Returns

Skew-symmetric matrix [batch_shape,3,3].