Linear algebra#

class ivy.data_classes.container.linear_algebra._ContainerWithLinearAlgebra(dict_in=None, queues=None, queue_load_sizes=None, container_combine_method='list_join', queue_timeout=None, print_limit=10, key_length_limit=None, print_indent=4, print_line_spacing=0, ivyh=None, default_key_color='green', keyword_color_dict=None, rebuild_child_containers=False, types_to_iteratively_nest=None, alphabetical_keys=True, dynamic_backend=None, build_callable=False, **kwargs)[source]#

Bases: ContainerBase

_abc_impl = <_abc._abc_data object>#
static _static_cholesky(x, /, *, upper=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.cholesky. This method simply wraps the function, and so the docstring for ivy.cholesky also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array or container having shape (…, M, M) and whose innermost two dimensions form square symmetric positive-definite matrices. Should have a floating-point data type.

  • upper (Union[bool, Container], default: False) – If True, the result must be the upper-triangular Cholesky factor U. If False, the result must be the lower-triangular Cholesky factor L. Default: False.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the Cholesky factors for each square matrix. If upper is False, the returned container must contain lower-triangular matrices; otherwise, the returned container must contain upper-triangular matrices. The returned container must have a floating-point data type determined by Type Promotion Rules and must have the same shape as self.

Examples

With one ivy.Container input: >>> x = ivy.Container(a=ivy.array([[3., -1.], [-1., 3.]]), … b=ivy.array([[2., 1.], [1., 1.]])) >>> y = ivy.Container.static_cholesky(x, upper=’false’) >>> print(y) {

a: ivy.array([[1.73, -0.577],

[0., 1.63]]),

b: ivy.array([[1.41, 0.707],

[0., 0.707]])

}

With multiple ivy.Container inputs: >>> x = ivy.Container(a=ivy.array([[3., -1], [-1., 3.]]), … b=ivy.array([[2., 1.], [1., 1.]])) >>> upper = ivy.Container(a=1, b=-1) >>> y = ivy.Container.static_roll(x, upper=False) >>> print(y) {

a: ivy.array([[3., 3.],

[-1., -1.]]),

b: ivy.array([[1., 1.],

[1., 2.]])

}

static _static_cross(x1, x2, /, *, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.cross. This method simply wraps the function, and so the docstring for ivy.cross also applies to this method with minimal changes.

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – first input array. Should have a numeric data type.

  • x2 (Union[Container, Array, NativeArray]) – second input array. Must be compatible with self (see broadcasting). Should have a numeric data type.

  • axis (Union[int, Container], default: -1) – the axis (dimension) of x1 and x2 containing the vectors for which to compute the cross product.vIf set to -1, the function computes the cross product for vectors defined by the last axis (dimension). Default: -1.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the element-wise products. The returned array must have a data type determined by type-promotion.

Examples

With one ivy.Container input:

>>> x = ivy.array([9., 0., 3.])
>>> y = ivy.Container(a=ivy.array([1., 1., 0.]), b=ivy.array([1., 0., 1.]))
>>> z = ivy.Container.static_cross(x, y)
>>> print(z)
{
    a: ivy.array([-3., 3., 9.]),
    b: ivy.array([0., -6., 0.])
}

With multiple ivy.Container inputs:

>>> x = x = ivy.Container(a=ivy.array([5., 0., 0.]), b=ivy.array([0., 0., 2.]))
>>> y = ivy.Container(a=ivy.array([0., 7., 0.]), b=ivy.array([3., 0., 0.]))
>>> z = ivy.Container.static_cross(x, y)
>>> print(z)
{
    a: ivy.array([0., 0., 35.]),
    b: ivy.array([0., 6., 0.])
}
static _static_det(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_diag(x, /, *, k=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_diagonal(x, /, *, offset=0, axis1=-2, axis2=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.diagonal. This method simply wraps the function, and so the docstring for ivy.diagonal also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) –

    input Container with leave arrays having shape

    (..., M, N) and whose innermost two dimensions form

    MxN matrices.

  • offset (Union[int, Container], default: 0) – offset specifying the off-diagonal relative to the main diagonal. - offset = 0: the main diagonal. - offset > 0: off-diagonal above the main diagonal. - offset < 0: off-diagonal below the main diagonal. Default: 0.

  • axis1 (Union[int, Container], default: -2) – axis to be used as the first axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to first axis (-2).

  • axis2 (Union[int, Container], default: -1) – axis to be used as the second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to second axis (-1).

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container with the diagonals. More details can be found in the docstring for ivy.diagonal.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[1., 2.], [3., 4.]],
...                   b=ivy.array([[5., 6.], [7., 8.]])))
>>> d = ivy.Container.static_diagonal(x)
>>> print(d)
{
    a:ivy.array([1., 4.]),
    b:ivy.array([5., 8.])
}
>>> a = ivy.array([[0, 1, 2],
...                [3, 4, 5],
...                [6, 7, 8]])
>>> b = ivy.array([[-1., -2., -3.],
...                 [-3., 4., 5.],
...                 [5., 6., 7.]])],
>>> x = ivy.Container(a=a, b=b)
>>> d = ivy.Container.static_diagonal(offset=-1, axis1=0)
>>> print(d)
{
    a:ivy.array([3., 7.]),
    b:ivy.array([-3., 6.])
}
static _static_eigh(x, /, *, UPLO='L', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_eigvalsh(x, /, *, UPLO='L', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.eigvalsh. This method simply wraps the function, and so the docstring for ivy.eigvalsh also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – Ivy container having shape (..., M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the computed eigenvalues. The returned array must have shape (…, M) and have the same data type as x.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[[1.,2.,3.],[2.,4.,5.],[3.,5.,6.]]]),
...                   b=ivy.array([[[1.,1.,2.],[1.,2.,1.],[2.,1.,1.]]]),
...                   c=ivy.array([[[2.,2.,2.],[2.,3.,3.],[2.,3.,3.]]]))
>>> e = ivy.Container.static_eigvalsh(x)
>>> print(e)
{
    a: ivy.array([[-0.51572949, 0.17091519, 11.3448143]]),
    b: ivy.array([[-1., 1., 4.]]),
    c: ivy.array([[-8.88178420e-16, 5.35898387e-01, 7.46410179e+00]])
}
static _static_inner(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.inner. This method simply wraps the function, and so the docstring for ivy.inner also applies to this method with minimal changes.

Return the inner product of two vectors x1 and x2.

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – first one-dimensional input array of size N. Should have a numeric data type. a(N,) array_like First input vector. Input is flattened if not already 1-dimensional.

  • x2 (Union[Array, NativeArray, Container]) – second one-dimensional input array of size M. Should have a numeric data type. b(M,) array_like Second input vector. Input is flattened if not already 1-dimensional.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a two-dimensional array containing the inner product and whose shape is (N, M). The returned array must have a data type determined by Type Promotion Rules.

Examples

>>> x1 = ivy.Container(a=ivy.array([[1, 2], [3, 4]]))
>>> x2 = ivy.Container(a=ivy.array([5, 6]))
>>> y = ivy.Container.static_inner(x1, x2)
>>> print(y)
{
    a: ivy.array([17, 39])
}
static _static_inv(x, /, *, adjoint=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.inv. This method simply wraps the function, and so the docstring for ivy.inv also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – Ivy container having shape (..., M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container containing the multiplicative inverses. The returned array must have a floating-point data type determined by type-promotion and must have the same shape as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[0., 1.], [4., 4.]]),
...                      b=ivy.array([[4., 4.], [2., 1.]]))
>>> y = ivy.Container.static_inv(x)
>>> print(y)
{
    a: ivy.array([[-1, 0.25], [1., 0.]]),
    b: ivy.array([-0.25, 1.], [0.5, -1.])
}
static _static_matmul(x1, x2, /, *, transpose_a=False, transpose_b=False, adjoint_a=False, adjoint_b=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.matmul. This method simply wraps the function, and so the docstring for ivy.matul also applies to this method with minimal changes.

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – first input array

  • x2 (Union[Array, NativeArray, Container]) – second input array

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – the matrix multiplication result of x1 and x2

Examples

>>> x = ivy.Container(a = ivy.array([[3., -1.], [-1., 3.]]) ,
...                   b = ivy.array([[2., 1.], [1., 1.]]))
>>> y = ivy.Container.static_matmul(x, x)
>>> print(y)
{
    a: ivy.array([[10., -6.],
                  [-6., 10.]]),
    b: ivy.array([[5., 3.],
                  [3., 2.]])
}
static _static_matrix_norm(x, /, *, ord='fro', axis=(-2, -1), keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.matrix_norm. This method simply wraps the function, and so the docstring for ivy.matrix_norm also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – Input array having shape (…, M, N) and whose innermost two deimensions form MxN matrices. Should have a floating-point data type.

  • ord (Union[int, float, Literal[inf, -inf, 'fro', 'nuc'], Container], default: 'fro') – Order of the norm. Default is “fro”.

  • axis (Tuple[int, int, Container], default: (-2, -1)) – specifies the axes that hold 2-D matrices. Default: (-2, -1).

  • keepdims (Union[bool, Container], default: False) – 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.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – Matrix norm of the array at specified axes.

Examples

>>> x = ivy.Container(a=ivy.array([[1.1, 2.2], [1., 2.]]),                               b=ivy.array([[1., 2.], [3., 4.]]))
>>> y = ivy.Container.static_matrix_norm(x, ord=1)
>>> print(y)
{
    a: ivy.array(4.2),
    b: ivy.array(6.)
}
>>> x = ivy.Container(a=ivy.arange(12, dtype=float).reshape((3, 2, 2)),                               b=ivy.arange(8, dtype=float).reshape((2, 2, 2)))
>>> ord = ivy.Container(a=1, b=float('inf'))
>>> axis = ivy.Container(a=(1, 2), b=(2, 1))
>>> k = ivy.Container(a=False, b=True)
>>> y = ivy.Container.static_matrix_norm(x, ord=ord, axis=axis, keepdims=k)
>>> print(y)
{
    a: ivy.array([4.24, 11.4, 19.2]),
    b: ivy.array([[[3.7]],
                  [[11.2]]])
}
static _static_matrix_power(x, n, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_matrix_rank(x, /, *, atol=None, rtol=None, hermitian=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.matrix_rank. This method returns the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices).

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array or container having shape (..., M, N) and whose innermost two dimensions form MxN matrices. Should have a floating-point data type.

  • atol (Optional[Union[float, Tuple[float], Container]], default: None) – absolute tolerance. When None it’s considered to be zero.

  • rtol (Optional[Union[float, Tuple[float], Container]], default: None) – relative tolerance for small singular values. Singular values approximately less than or equal to rtol * largest_singular_value are set to zero. If a float, the value is equivalent to a zero-dimensional array having a floating-point data type determined by type-promotion (as applied to x) and must be broadcast against each matrix. If an array, must have a floating-point data type and must be compatible with shape(x)[:-2] (see:ref:broadcasting). If None, the default value is max(M, N) * eps, where eps must be the machine epsilon associated with the floating-point data type determined by type-promotion (as applied to x). Default: None.

  • hermitian (Optional[Union[bool, Container]], default: False) – indicates whether x is Hermitian. When hermitian=True, x is assumed to be Hermitian, enabling a more efficient method for finding eigenvalues, but x is not checked inside the function. Instead, We just use the lower triangular of the matrix to compute. Default: False.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the ranks. The returned array must have a floating-point data type determined by type-promotion and must have shape (...) (i.e., must have a shape equal to shape(x)[:-2]).

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[1., 0.], [0., 1.]]),
...                   b=ivy.array([[1., 0.], [0., 0.]]))
>>> y = ivy.Container.static_matrix_rank(x)
>>> print(y)
{
    a: ivy.array(2.),
    b: ivy.array(1.)
}
static _static_matrix_transpose(x, /, *, conjugate=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Transpose a matrix (or a stack of matrices) x.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input Container which will have arrays with shape (..., M, N) and whose innermost two dimensions form MxN matrices.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container with the transposes for each matrix and having shape (..., N, M). The returned array must have the same data type as x.

Examples

With ivy.Container instance method:

>>> x = ivy.Container(a=ivy.array([[1., 1.], [0., 3.]]),                         b=ivy.array([[0., 4.], [3., 1.]]))
>>> y = ivy.Container.static_matrix_transpose(x)
>>> print(y)
{
    a: ivy.array([[1., 0.],
                  [1., 3.]]),
    b: ivy.array([[0., 3.],
                  [4., 1.]])
}
static _static_outer(x1, x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.outer. This method simply wraps the function, and so the docstring for ivy.outer also applies to this method with minimal changes.

Computes the outer product of two arrays, x1 and x2, by computing the tensor product along the last dimension of both arrays.

Parameters:
  • x1 (Union[Array, NativeArray, Container]) – first input array having shape (…, N1)

  • x2 (Union[Array, NativeArray, Container]) – second input array having shape (…, N2)

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. The container must have shape (…, N1, N2). The first x1.ndim-1 dimensions must have the same size as those of the input array x1 and the first x2.ndim-1 dimensions must have the same size as those of the input array x2.

Return type:

Container

Returns:

ret – an ivy container whose shape is (…, N1, N2). The first x1.ndim-1 dimensions have the same size as those of the input array x1 and the first x2.ndim-1 dimensions have the same size as those of the input array x2.

Example

>>> x1 =ivy.Container( a=ivy.array([[1, 2, 3], [4, 5, 6]]))
>>> x2 = ivy.Container(a=ivy.array([1, 2, 3]))
>>> y = ivy.Container.static_outer(x1, x2)
>>> print(y)
ivy.array([[[ 1.,  2.,  3.],
            [ 2.,  4.,  6.],
            [ 3.,  6.,  9.]],
           [[ 4.,  8., 12.],
            [ 5., 10., 15.],
            [ 6., 12., 18.]]])
static _static_pinv(x, /, *, rtol=None, out=None)[source]#

ivy.Container special method variant of ivy.pinv. This method simply wraps the function, and so the docstring for ivy.pinv also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array having shape (..., M, N) and whose innermost two dimensions form``MxN`` matrices. Should have a floating-point data type.

  • rtol (Optional[Union[float, Tuple[float], Container]], default: None) – relative tolerance for small singular values approximately less than or equal to rtol * largest_singular_value are set to zero.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the pseudo-inverses. The returned array must have a floating-point data type determined by type-promotion and must have shape (..., N, M) (i.e., must have the same shape as x, except the innermost two dimensions must be transposed).

Examples

>>> x = ivy.Container(a= ivy.array([[1., 2.], [3., 4.]]))
>>> y = ivy.Container.static_pinv(x)
>>> print(y)
{
    a: ivy.array([[-2., 1.],
                  [1.5, -0.5]])
}
>>> x = ivy.Container(a=ivy.array([[1., 2.], [3., 4.]]))
>>> out = ivy.Container(a=ivy.zeros((2, 2)))
>>> ivy.Container.static_pinv(x, rtol=1e-1, out=out)
>>> print(out)
{
    a: ivy.array([[0.0426, 0.0964],
                  [0.0605, 0.1368]])
}
static _static_qr(x, /, *, mode='reduced', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.qr. This method simply wraps the function, and so the docstring for ivy.qr also applies to this method with minimal changes.

Returns the qr decomposition x = QR of a full column rank matrix (or a stack of matrices), where Q is an orthonormal matrix (or a stack of matrices) and R is an upper-triangular matrix (or a stack of matrices).

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container having shape (…, M, N) and whose innermost two dimensions form MxN matrices of rank N. Should have a floating-point data type.

  • mode (Union[str, Container], default: 'reduced') – decomposition mode. Should be one of the following modes: - ‘reduced’: compute only the leading K columns of q, such that q and r have dimensions (…, M, K) and (…, K, N), respectively, and where K = min(M, N). - ‘complete’: compute q and r with dimensions (…, M, M) and (…, M, N), respectively. Default: ‘reduced’.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Tuple[Container, Container]], default: None) – optional output tuple of containers, for writing the result to. The arrays must have shapes that the inputs broadcast to.

Return type:

Tuple[Container, Container]

Returns:

ret – a namedtuple (Q, R) whose - first element must have the field name Q and must be an container whose shape depends on the value of mode and contain matrices with orthonormal columns. If mode is ‘complete’, the container must have shape (…, M, M). If mode is ‘reduced’, the container must have shape (…, M, K), where K = min(M, N). The first x.ndim-2 dimensions must have the same size as those of the input container x. - second element must have the field name R and must be an container whose shape depends on the value of mode and contain upper-triangular matrices. If mode is ‘complete’, the container must have shape (…, M, N). If mode is ‘reduced’, the container must have shape (…, K, N), where K = min(M, N). The first x.ndim-2 dimensions must have the same size as those of the input x.

Examples

>>> x = ivy.Container(a = ivy.native_array([[1., 2.], [3., 4.]]),
...                   b = ivy.array([[2., 3.], [4. ,5.]]))
>>> q,r = ivy.Container.static_qr(x, mode='complete')
>>> print(q)
{
    a: ivy.array([[-0.31622777, -0.9486833],
                [-0.9486833, 0.31622777]]),
    b: ivy.array([[-0.4472136, -0.89442719],
                [-0.89442719, 0.4472136]])
}
>>> print(r)
{
    a: ivy.array([[-3.16227766, -4.42718872],
                [0., -0.63245553]]),
    b: ivy.array([[-4.47213595, -5.81377674],
                [0., -0.4472136]])
}
static _static_slogdet(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container static method variant of ivy.slogdet. This method simply wraps the function, and so the docstring for ivy.slogdet also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array or container having shape (…, M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

Return type:

Container

Returns:

ret – This function returns a container containing NamedTuples. Each NamedTuple of output will have -

sign: An array containing a number representing the sign of the determinant for each square matrix.

logabsdet: An array containing natural log of the absolute determinant of each square matrix.

Examples

>>> x = ivy.Container(a=ivy.array([[1.0, 2.0],
...                                [3.0, 4.0]]),
...                   b=ivy.array([[1.0, 2.0],
...                                [2.0, 1.0]]))
>>> y = ivy.Container.static_slogdet(x)
>>> print(y)
{
    a: [
        sign = ivy.array(-1.),
        logabsdet = ivy.array(0.6931472)
    ],
    b: [
        sign = ivy.array(-1.),
        logabsdet = ivy.array(1.0986123)
    ]
}
static _static_solve(x1, x2, /, *, adjoint=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_svd(x, /, *, compute_uv=True, full_matrices=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.svd. This method simply wraps the function, and so the docstring for ivy.svd also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container with array leaves having shape (..., M, N) and whose innermost two dimensions form matrices on which to perform singular value decomposition. Should have a floating-point data type.

  • full_matrices (Union[bool, Container], default: True) – If True, compute full-sized U and Vh, such that U has shape (..., M, M) and Vh has shape (..., N, N). If False, compute on the leading K singular vectors, such that U has shape (..., M, K) and Vh has shape (..., K, N) and where K = min(M, N). Default: True.

  • compute_uv (Union[bool, Container], default: True) – If True then left and right singular vectors will be computed and returned in U and Vh, respectively. Otherwise, only the singular values will be computed, which can be significantly faster.

  • note:: (..) – with backend set as torch, svd with still compute left and right singular vectors irrespective of the value of compute_uv, however Ivy will still only return the singular values.

Return type:

Union[Container, Tuple[Container, ...]]

Returns:

  • .. note:: – once complex numbers are supported, each square matrix must be Hermitian.

  • ret – A container of a namedtuples (U, S, Vh). More details in ivy.svd.

Examples

With ivy.Container input:

>>> x = ivy.random_normal(shape = (9, 6))
>>> y = ivy.random_normal(shape = (2, 4))
>>> z = ivy.Container(a=x, b=y)
>>> ret = ivy.Container.static_svd(z)
>>> aU, aS, aVh = ret.a
>>> bU, bS, bVh = ret.b
>>> print(aU.shape, aS.shape, aVh.shape, bU.shape, bS.shape, bVh.shape)
(9, 9) (6,) (6, 6) (2, 2) (2,) (4, 4)
static _static_svdvals(x, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_tensordot(x1, x2, /, *, axes=2, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_tensorsolve(x1, x2, /, *, axes=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_trace(x, /, *, offset=0, axis1=0, axis2=1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.trace. This method Returns the sum along the specified diagonals of a matrix (or a stack of matrices).

Parameters:
  • x (Union[Array, NativeArray, Container]) – input container having shape (..., M, N) and whose innermost two dimensions form MxN matrices. Should have a floating-point data type.

  • offset (Union[int, Container], default: 0) – Offset of the diagonal from the main diagonal. Can be both positive and negative. Defaults to 0.

  • axis1 (Union[int, Container], default: 0) – axis to be used as the first axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to 0. .

  • axis2 (Union[int, Container], default: 1) – axis to be used as the second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to 1. .

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the traces and whose shape is determined by removing the last two dimensions and storing the traces in the last array dimension. For example, if x has rank k and shape (I, J, K, ..., L, M, N), then an output array has rank k-2 and shape (I, J, K, ..., L) where

out[i, j, k, …, l] = trace(a[i, j, k, …, l, :, :])

The returned array must have the same data type as x.

Examples

With ivy.Container input: >>> x = ivy.Container( … a = ivy.array([[7, 1, 2], … [1, 3, 5], … [0, 7, 4]]), … b = ivy.array([[4, 3, 2], … [1, 9, 5], … [7, 0, 6]]) ) >>> y = x.Container.static_trace(x) >>> print(y) {

a: ivy.array(14), b: ivy.array(19)

}

static _static_vander(x, /, *, N=None, increasing=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.vander. This method simply wraps the function, and so the docstring for ivy.vander also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – ivy container that contains 1-D arrays.

  • N (Optional[Union[int, Container]], default: None) – Number of columns in the output. If N is not specified, a square array is returned (N = len(x))

  • increasing (Union[bool, Container], default: False) – Order of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – container that contains the Vandermonde matrix of the arrays included in the input container.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(
        a = ivy.array([1, 2, 3, 5])
        b = ivy.array([6, 7, 8, 9])
    )
>>> ivy.Container.static_vander(x)
{
    a: ivy.array(
            [[  1,   1,   1,   1],
            [  8,   4,   2,   1],
            [ 27,   9,   3,   1],
            [125,  25,   5,   1]]
            ),
    b: ivy.array(
            [[216,  36,   6,   1],
            [343,  49,   7,   1],
            [512,  64,   8,   1],
            [729,  81,   9,   1]]
            )
}
static _static_vecdot(x1, x2, /, *, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static _static_vector_norm(x, /, *, axis=None, keepdims=False, ord=2, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.vector_norm. This method simply wraps the function, and so the docstring for ivy.vector_norm also applies to this method with minimal changes.

Parameters:
  • x (Union[Array, NativeArray, Container]) – input array. Should have a floating-point data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) –

    If an integer, axis specifies the axis (dimension) along which to compute vector norms. If an n-tuple, axis specifies the axes (dimensions) along which to compute batched vector norms. If None, the

    vector norm must be computed over all array values (i.e., equivalent to computing the vector norm of

    a flattened array). Negative indices must be supported. Default: None.

  • keepdims (Union[bool, Container], default: False) – If True, the axes (dimensions) specified by axis must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting). Otherwise, if False, the axes (dimensions) specified by axis must not be included in the result. Default: False.

  • ord (Union[int, float, Literal[inf, -inf], Container], default: 2) –

    order of the norm. The following mathematical norms must be supported:

    ord

    description

    1

    L1-norm (Manhattan)

    2

    L2-norm (Euclidean)

    inf

    infinity norm

    (int,float >= 1)

    p-norm

    The following non-mathematical “norms” must be supported:

    Default: 2.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – data type that may be used to perform the computation more precisely. The input array x gets cast to dtype before the function’s computations.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the vector norms. If axis is None, the returned array must be a zero-dimensional array containing a vector norm. If axis is a scalar value (int or float), the returned array must have a rank which is one less than the rank of x. If axis is a n-tuple, the returned array must have

a rank which is n less than the rank of x. The returned

array must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.Container(a = [1., 2., 3.], b = [-2., 0., 3.2])
>>> y = ivy.Container.static_vector_norm(x)
>>> print(y)
{
    a: ivy.array([3.7416575]),
    b: ivy.array([3.77359247])
}
static _static_vector_to_skew_symmetric_matrix(vector, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

cholesky(*, upper=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.cholesky. This method simply wraps the function, and so the docstring for ivy.cholesky also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container having shape (…, M, M) and whose innermost two dimensions form square symmetric positive-definite matrices. Should have a floating-point data type.

  • upper (Union[bool, Container], default: False) – If True, the result must be the upper-triangular Cholesky factor U. If False, the result must be the lower-triangular Cholesky factor L. Default: False.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the Cholesky factors for each square matrix. If upper is False, the returned container must contain lower-triangular matrices; otherwise, the returned container must contain upper-triangular matrices. The returned container must have a floating-point data type determined by Type Promotion Rules and must have the same shape as self.

Examples

>>> x = ivy.Container(a=ivy.array([[3., -1],[-1., 3.]]),
...                      b=ivy.array([[2., 1.],[1., 1.]]))
>>> y = x.cholesky(upper='false')
>>> print(y)
{
    a: ivy.array([[1.73, -0.577],
                    [0., 1.63]]),
    b: ivy.array([[1.41, 0.707],
                    [0., 0.707]])
}
cross(x2, /, *, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.cross. This method simply wraps the function, and so the docstring for ivy.cross also applies to this method with minimal changes.

Parameters:
  • self (Container) – first input array. Should have a numeric data type.

  • x2 (Union[Container, Array, NativeArray]) – second input array. Must be compatible with self (see broadcasting). Should have a numeric data type.

  • axis (Union[int, Container], default: -1) – the axis (dimension) of x1 and x2 containing the vectors for which to compute (default: -1) the cross product.vIf set to -1, the function computes the cross product for vectors defined by the last axis (dimension). Default: -1.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the element-wise products. The returned array must have a data type determined by type-promotion.

Examples

>>> x = ivy.Container(a=ivy.array([5., 0., 0.]), b=ivy.array([0., 0., 2.]))
>>> y = ivy.Container(a=ivy.array([0., 7., 0.]), b=ivy.array([3., 0., 0.]))
>>> z = x.cross(y)
>>> print(z)
{
    a: ivy.array([0., 0., 35.]),
    b: ivy.array([0., 6., 0.])
}
det(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

Examples

>>> x = ivy.Container(a = ivy.array([[3., -1.], [-1., 3.]]) ,
...                   b = ivy.array([[2., 1.], [1., 1.]]))
>>> y = x.det()
>>> print(y)
{a:ivy.array(8.),b:ivy.array(1.)}
diag(*, k=0, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.diag. This method simply wraps the function, and so the docstring for ivy.diag also applies to this method with minimal changes.

Return type:

Container

Examples

>>> x = ivy.Container(a=[[0, 1, 2],
>>>                      [3, 4, 5],
>>>                      [6, 7, 8]])
>>> ivy.diag(x, k=1)
{
    a: ivy.array([1, 5])
}
diagonal(*, offset=0, axis1=-2, axis2=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.diagonal. This method simply wraps the function, and so the docstring for ivy.diagonal also applies to this method with minimal changes.

Parameters:
  • self (Container) –

    input Container with leave arrays having shape

    (..., M, N) and whose innermost two dimensions form

    MxN matrices.

  • offset (Union[int, Container], default: 0) – offset specifying the off-diagonal relative to the main diagonal. - offset = 0: the main diagonal. - offset > 0: off-diagonal above the main diagonal. - offset < 0: off-diagonal below the main diagonal. Default: 0.

  • axis1 (Union[int, Container], default: -2) – axis to be used as the first axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to first axis (-2).

  • axis2 (Union[int, Container], default: -1) – axis to be used as the second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to second axis (-1).

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container with the diagonals. More details can be found in the docstring for ivy.diagonal.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[1., 2.], [3., 4.]]),
...                   b=ivy.array([[5., 6.], [7., 8.]]))
>>> d = x.diagonal()
>>> print(d)
{
    a:ivy.array([1., 4.]),
    b:ivy.array([5., 8.])
}
>>> a = ivy.array([[0, 1, 2],
...                [3, 4, 5],
...                [6, 7, 8]])
>>> b = ivy.array([[-1., -2., -3.],
...                 [-3., 4., 5.],
...                 [5., 6., 7.]]),
>>> x = ivy.Container(a=a, b=b)
>>> d = x.diagonal(offset=-1)
>>> print(d)
{
    a: ivy.array([3, 7]),
    b: ivy.array([[-3., 6.]])
}
eigh(*, UPLO='L', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.eigh. This method simply wraps the function, and so the docstring for ivy.eigh also applies to this method with minimal changes.

Parameters:
  • self (ivy.Container) – Ivy container having shape (…, M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • UPLO (str, optional) – Specifies whether the upper or lower triangular part of the Hermitian matrix should be used for the eigenvalue decomposition. Default is ‘L’.

  • key_chains (Union[List[str], Dict[str, str]], optional) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (bool, optional) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (bool, optional) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (bool, optional) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (ivy.Container, optional) – Optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ivy.Container – A container containing the computed eigenvalues. The returned array must have shape (…, M) and have the same data type as self.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[[1.,2.],[2.,1.]]]),
...                   b=ivy.array([[[2.,4.],[4.,2.]]]))
>>> y = x.eigh()
>>> print(y)
{
    a: ivy.array([[-1., 3.]]),
    b: ivy.array([[-2., 6.]])
}
eigvalsh(*, UPLO='L', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.eigvalsh. This method simply wraps the function, and so the docstring for ivy.eigvalsh also applies to this method with minimal changes.

Parameters:
  • self (Container) – Ivy container having shape (..., M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the computed eigenvalues. The returned array must have shape (…, M) and have the same data type as x.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(a=ivy.array([[[1.,2.],[2.,1.]]]),
...                   b=ivy.array([[[2.,4.],[4.,2.]]]))
>>> y = ivy.eigvalsh(x)
>>> print(y)
{
    a: ivy.array([[-1., 3.]]),
    b: ivy.array([[-2., 6.]])
}
general_inner_product(x2, n_modes=None, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.general_inner_product.

This method simply wraps the function, and so the docstring for ivy.general_inner_product also applies to this method with minimal changes.

Return type:

Container

inner(x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.inner. This method simply wraps the function, and so the docstring for ivy.inner also applies to this method with minimal changes.

Return the inner product of two vectors self and x2.

Parameters:
  • self (Container) – input container of size N. Should have a numeric data type. a(N,) array_like First input vector. Input is flattened if not already 1-dimensional.

  • x2 (Union[Container, Array, NativeArray]) – one-dimensional input array of size M. Should have a numeric data type. b(M,) array_like Second input vector. Input is flattened if not already 1-dimensional.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a new container representing the inner product and whose shape is (N, M). The returned array must have a data type determined by Type Promotion Rules.

Examples

>>> x1 = ivy.Container(a=ivy.array([[1, 2], [3, 4]]))
>>> x2 = ivy.Container(a=ivy.array([5, 6]))
>>> y = ivy.Container.inner(x1, x2)
>>> print(y)
{
    a: ivy.array([17, 39])
}
inv(*, adjoint=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.inv. This method simply wraps the function, and so the docstring for ivy.inv also applies to this method with minimal changes.

Parameters:
  • self (Container) – Ivy container having shape (..., M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container containing the multiplicative inverses. The returned array must have a floating-point data type determined by type-promotion and must have the same shape as x.

Examples

With ivy.Container input:

>>> x = ivy.Container(a=ivy.array([[0., 1.], [4., 4.]]),
...                      b=ivy.array([[4., 4.], [2., 1.]]))
>>> y = x.inv()
>>> print(y)
{
    a: ivy.array([[-1, 0.25], [1., 0.]]),
    b: ivy.array([-0.25, 1.], [0.5, -1.])
}
matmul(x2, /, *, transpose_a=False, transpose_b=False, adjoint_a=False, adjoint_b=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.matmul. This method simply wraps the function, and so the docstring for ivy.matmul also applies to this method with minimal changes.

Parameters:
  • self (Container) – first input array

  • x2 (Union[Container, Array, NativeArray]) – second input array

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output container, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – the matrix multiplication result of self and x2

Examples

>>> x = ivy.Container(a = ivy.array([[3., -1.], [-1., 3.]]) ,
...                   b = ivy.array([[2., 1.], [1., 1.]]))
>>> y = x.matmul(x)
>>> print(y)
{
    a: ivy.array([[10., -6.],
                  [-6., 10.]]),
    b: ivy.array([[5., 3.],
                  [3., 2.]])
}
matrix_norm(*, ord='fro', axis=(-2, -1), keepdims=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.matrix_norm. This method simply wraps the function, and so the docstring for ivy.matrix_norm also applies to this method with minimal changes.

Parameters:
  • self (Container) – Container having shape (…, M, N) and whose innermost two dimensions form MxN matrices. Should have a floating-point data type.

  • ord (Union[int, float, Literal[inf, -inf, 'fro', 'nuc'], Container], default: 'fro') – Order of the norm. Default is “fro”.

  • axis (Tuple[int, int, Container], default: (-2, -1)) – specifies the axes that hold 2-D matrices. Default: (-2, -1).

  • keepdims (Union[bool, Container], default: False) – 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.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – Matrix norm of the array at specified axes.

Examples

>>> x = ivy.Container(a=ivy.array([[1.1, 2.2], [1., 2.]]),                               b=ivy.array([[1., 2.], [3., 4.]]))
>>> y = x.matrix_norm(ord=1)
>>> print(y)
{
    a: ivy.array(4.2),
    b: ivy.array(6.)
}
>>> x = ivy.Container(a=ivy.arange(12, dtype=float).reshape((3, 2, 2)),                               b=ivy.arange(8, dtype=float).reshape((2, 2, 2)))
>>> ord = ivy.Container(a="nuc", b=ivy.inf)
>>> axis = ivy.Container(a=(1, 2), b=(2, 1))
>>> k = ivy.Container(a=True, b=False)
>>> y = x.matrix_norm(ord=ord, axis=axis, keepdims=k)
>>> print(y)
{
    a: ivy.array([[[4.24]],
                 [[11.4]],
                 [[19.2]]]),
    b: ivy.array([4., 12.])
}
matrix_power(n, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

matrix_rank(*, atol=None, rtol=None, hermitian=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.matrix_rank. This method returns the rank (i.e., number of non-zero singular values) of a matrix (or a stack of matrices).

Parameters:
  • self (Container) – input container having shape (..., M, N) and whose innermost two dimensions form MxN matrices. Should have a floating-point data type.

  • atol (Optional[Union[float, Tuple[float], Container]], default: None) – absolute tolerance. When None it’s considered to be zero.

  • rtol (Optional[Union[float, Tuple[float], Container]], default: None) – relative tolerance for small singular values. Singular values approximately less than or equal to rtol * largest_singular_value are set to zero. If a float, the value is equivalent to a zero-dimensional array having a floating-point data type determined by type-promotion (as applied to x) and must be broadcast against each matrix. If an array, must have a floating-point data type and must be compatible with shape(x)[:-2] (see broadcasting). If None, the default value is max(M, N) * eps, where eps must be the machine epsilon associated with the floating-point data type determined by type-promotion (as applied to x). Default: None.

  • hermitian (Optional[Union[bool, Container]], default: False) – indicates whether x is Hermitian. When hermitian=True, x is assumed to be Hermitian, enabling a more efficient method for finding eigenvalues, but x is not checked inside the function. Instead, We just use the lower triangular of the matrix to compute. Default: False.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the ranks. The returned array must have a floating-point data type determined by type-promotion and must have shape (...) (i.e., must have a shape equal to shape(x)[:-2]).

Examples

With ivy.Container input: >>> x = ivy.Container(a=ivy.array([[1., 0.], [0., 1.]]), … b=ivy.array([[1., 0.], [0., 0.]])) >>> y = x.matrix_rank() >>> print(y) {

a: ivy.array(2), b: ivy.array(1)

}

matrix_transpose(*, conjugate=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Transpose a matrix (or a stack of matrices) x.

Parameters:
  • self (Container) – input Container which will have arrays with shape (..., M, N) and whose innermost two dimensions form MxN matrices.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – A container with the transposes for each matrix and having shape (..., N, M). The returned array must have the same data type as x.

Examples

With ivy.Container instance method:

>>> x = ivy.Container(a=ivy.array([[1., 1.], [0., 3.]]),                       b=ivy.array([[0., 4.], [3., 1.]]))
>>> y = x.matrix_transpose()
>>> print(y)
{
    a: ivy.array([[1., 0.],
                  [1., 3.]]),
    b: ivy.array([[0., 3.],
                  [4., 1.]])
}
outer(x2, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

Return the outer product of two arrays or containers.

The instance method implementation of the static method static_outer of the ivy.Container class. It calculates the outer product of two input arrays or containers along the last dimension and returns the resulting container. The input arrays should be either ivy.Container, ivy.Array, or ivy.NativeArray. The output container shape is the concatenation of the shapes of the input containers along the last dimension.

Parameters:
  • self (ivy.Container) – Input container of shape (…,B) where the last dimension represents B elements.

  • x2 (Union[ivy.Container, ivy.Array, ivy.NativeArray]) – Second input array or container of shape (…, N) where the last dimension represents N elements.

  • key_chains (Optional[Union[List[str], Dict[str, str]]]) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (bool) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped.Default is True.

  • prune_unapplied (bool) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (bool) – Whether to also map the method to sequences (lists, tuples). Default is False.

  • out (Optional[ivy.Container]) – Optional output container to write the result to. If not provided, a new container will be created.

Return type:

Container

Returns:

ivy.Container – A new container of shape (…, M, N) representing the outer product of the input arrays or containers along the last dimension.

Examples

>>> x = ivy.array([[1., 2.],[3., 4.]])
>>> y = ivy.array([[5., 6.],[7., 8.]])
>>> d = ivy.outer(x,y)
>>> print(d)
ivy.array([[ 5.,  6.,  7.,  8.],
            [10., 12., 14., 16.],
            [15., 18., 21., 24.],
            [20., 24., 28., 32.]])
pinv(*, rtol=None, out=None)[source]#

ivy.Container instance method variant of ivy.pinv. This method simply wraps the function, and so the docstring for ivy.pinv also applies to this method with minimal changes.

Parameters:
  • x – input array having shape (..., M, N) and whose innermost two dimensions form``MxN`` matrices. Should have a floating-point data type.

  • rtol (Optional[Union[float, Tuple[float], Container]], default: None) – relative tolerance for small singular values approximately less than or equal to rtol * largest_singular_value are set to zero.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the pseudo-inverses. The returned array must have a floating-point data type determined by type-promotion and must have shape (..., N, M) (i.e., must have the same shape as x, except the innermost two dimensions must be transposed).

Examples

>>> x = ivy.Container(a= ivy.array([[1., 2.], [3., 4.]]))
>>> y = x.pinv()
>>> print(y)
{
    a: ivy.array([[-1.99999988, 1.],
                  [1.5, -0.5]])
}
>>> x = ivy.Container(a = ivy.array([[1., 2.], [3., 4.]]))
>>> out = ivy.Container(a = ivy.zeros(x["a"].shape))
>>> x.pinv(out=out)
>>> print(out)
{
    a: ivy.array([[-1.99999988, 1.],
                  [1.5, -0.5]])
}
qr(*, mode='reduced', key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.qr. This method simply wraps the function, and so the docstring for ivy.qr also applies to this method with minimal changes.

Returns the qr decomposition x = QR of a full column rank matrix (or a stack of matrices), where Q is an orthonormal matrix (or a stack of matrices) and R is an upper-triangular matrix (or a stack of matrices).

Parameters:
  • self (Container) – input container having shape (…, M, N) and whose innermost two dimensions form MxN matrices of rank N. Should have a floating-point data type.

  • mode (Union[str, Container], default: 'reduced') – decomposition mode. Should be one of the following modes: - ‘reduced’: compute only the leading K columns of q, such that q and r have dimensions (…, M, K) and (…, K, N), respectively, and where K = min(M, N). - ‘complete’: compute q and r with dimensions (…, M, M) and (…, M, N), respectively. Default: ‘reduced’.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Tuple[Container, Container]], default: None) – optional output tuple of containers, for writing the result to. The arrays must have shapes that the inputs broadcast to.

Return type:

Tuple[Container, Container]

Returns:

ret – a namedtuple (Q, R) whose - first element must have the field name Q and must be an container whose shape depends on the value of mode and contain matrices with orthonormal columns. If mode is ‘complete’, the container must have shape (…, M, M). If mode is ‘reduced’, the container must have shape (…, M, K), where K = min(M, N). The first x.ndim-2 dimensions must have the same size as those of the input container x. - second element must have the field name R and must be an container whose shape depends on the value of mode and contain upper-triangular matrices. If mode is ‘complete’, the container must have shape (…, M, N). If mode is ‘reduced’, the container must have shape (…, K, N), where K = min(M, N). The first x.ndim-2 dimensions must have the same size as those of the input x.

Examples

>>> x = ivy.Container(a = ivy.native_array([[1., 2.], [3., 4.]]),
...                   b = ivy.array([[2., 3.], [4. ,5.]]))
>>> q,r = x.qr(mode='complete')
>>> print(q)
{
    a: ivy.array([[-0.31622777, -0.9486833],
                [-0.9486833, 0.31622777]]),
    b: ivy.array([[-0.4472136, -0.89442719],
                [-0.89442719, 0.4472136]])
}
>>> print(r)
{
    a: ivy.array([[-3.16227766, -4.42718872],
                [0., -0.63245553]]),
    b: ivy.array([[-4.47213595, -5.81377674],
                [0., -0.4472136]])
}
slogdet(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False)[source]#

ivy.Container instance method variant of ivy.slogdet. This method simply wraps the function, and so the docstring for ivy.slogdet also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container having shape (…, M, M) and whose innermost two dimensions form square matrices. Should have a floating-point data type.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

Return type:

Container

Returns:

ret – This function returns container containing NamedTuples. Each NamedTuple of output will have -

sign: An array of a number representing the sign of the determinant of each square.

logabsdet: An array of the natural log of the absolute value of the determinant of each square.

Examples

>>> x = ivy.Container(a=ivy.array([[1.0, 2.0],
...                                [3.0, 4.0]]),
...                   b=ivy.array([[1.0, 2.0],
...                                [2.0, 1.0]]))
>>> y = x.slogdet()
>>> print(y)
[{
    a: ivy.array(-1.),
    b: ivy.array(-1.)
}, {
    a: ivy.array(0.69314718),
    b: ivy.array(1.09861231)
}]
solve(x2, /, *, adjoint=False, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

static static_general_inner_product(x1, x2, n_modes=None, /, *, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container static method variant of ivy.general_inner_product. This method simply wraps the function, and so the docstring for ivy.general_inner_product also applies to this method with minimal changes.

Parameters:
  • x1 (Union[Container, Array, NativeArray]) – First input container containing input array.

  • x2 (Union[Container, Array, NativeArray]) – First input container containing input array.

  • n_modes (Optional[Union[int, Container]], default: None) – int, default is None. If None, the traditional inner product is returned (i.e. a float) otherwise, the product between the n_modes last modes of x1 and the n_modes first modes of x2 is returned. The resulting tensor’s order is len(x1) - n_modes.

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – Alternate output container in which to place the result. The default is None.

Return type:

Container

Returns:

ret – Container including the inner product tensor.

Examples

>>> x = ivy.Container(
        a=ivy.reshape(ivy.arange(4), (2, 2)),
        b=ivy.reshape(ivy.arange(8), (2, 4)),
    )
>>> ivy.Container.general_inner_product(x, 1)
    {
        a: ivy.array(6),
        b: ivy.array(28)
    }
svd(*, compute_uv=True, full_matrices=True, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.svd. This method simply wraps the function, and so the docstring for ivy.svd also applies to this method with minimal changes.

Parameters:
  • self (Container) – input container with array leaves having shape (..., M, N) and whose innermost two dimensions form matrices on which to perform singular value decomposition. Should have a floating-point data type.

  • full_matrices (Union[bool, Container], default: True) – If True, compute full-sized U and Vh, such that U has shape (..., M, M) and Vh has shape (..., N, N). If False, compute on the leading K singular vectors, such that U has shape (..., M, K) and Vh has shape (..., K, N) and where K = min(M, N). Default: True.

  • compute_uv (Union[bool, Container], default: True) – If True then left and right singular vectors will be computed and returned in U and Vh, respectively. Otherwise, only the singular values will be computed, which can be significantly faster.

  • note:: (..) – with backend set as torch, svd with still compute left and right singular vectors irrespective of the value of compute_uv, however Ivy will still only return the singular values.

Return type:

Container

Returns:

  • .. note:: – once complex numbers are supported, each square matrix must be Hermitian.

  • ret – A container of a namedtuples (U, S, Vh). More details in ivy.svd.

Examples

With ivy.Container input:

>>> x = ivy.random_normal(shape = (9, 6))
>>> y = ivy.random_normal(shape = (2, 4))
>>> z = ivy.Container(a=x, b=y)
>>> ret = z.svd()
>>> print(ret[0], ret[1], ret[2])
{
    a: (<class ivy.data_classes.array.array.Array> shape=[9, 9]),
    b: ivy.array([[-0.3475602, -0.93765765],
                  [-0.93765765, 0.3475602]])
} {
    a: ivy.array([3.58776021, 3.10416126, 2.80644298, 1.87024701, 1.48127627,
                  0.79101127]),
    b: ivy.array([1.98288572, 0.68917423])
} {
    a: (<class ivy.data_classes.array.array.Array> shape=[6, 6]),
    b: (<class ivy.data_classes.array.array.Array> shape=[4, 4])
}
svdvals(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

tensordot(x2, /, *, axes=2, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

tensorsolve(x2, /, *, axes=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

trace(*, offset=0, axis1=0, axis2=1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.trace. This method Returns the sum along the specified diagonals of a matrix (or a stack of matrices).

Parameters:
  • self (Container) – input container having shape (..., M, N) and whose innermost two dimensions form MxN matrices. Should have a floating-point data type.

  • offset (Union[int, Container], default: 0) – Offset of the diagonal from the main diagonal. Can be both positive and negative. Defaults to 0.

  • axis1 (Union[int, Container], default: 0) – axis to be used as the first axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to 0. .

  • axis2 (Union[int, Container], default: 1) – axis to be used as the second axis of the 2-D sub-arrays from which the diagonals should be taken. Defaults to 1. .

  • key_chains (Optional[Union[List[str], Dict[str, str], Container]], default: None) – The key-chains to apply or not apply the method to. Default is None.

  • to_apply (Union[bool, Container], default: True) – If True, the method will be applied to key_chains, otherwise key_chains will be skipped. Default is True.

  • prune_unapplied (Union[bool, Container], default: False) – Whether to prune key_chains for which the function was not applied. Default is False.

  • map_sequences (Union[bool, Container], default: False) – Whether to also map method to sequences (lists, tuples). Default is False.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – a container containing the traces and whose shape is determined by removing the last two dimensions and storing the traces in the last array dimension. For example, if x has rank k and shape (I, J, K, ..., L, M, N), then an output array has rank k-2 and shape (I, J, K, ..., L) where

out[i, j, k, …, l] = trace(a[i, j, k, …, l, :, :])

The returned array must have the same data type as x.

Examples

With ivy.Container input: >>> x = ivy.Container( … a = ivy.array([[7, 1, 2], … [1, 3, 5], … [0, 7, 4]]), … b = ivy.array([[4, 3, 2], … [1, 9, 5], … [7, 0, 6]])) >>> y = x.trace() >>> print(y) {

a: ivy.array(14), b: ivy.array(19)

}

vander(*, N=None, increasing=False, out=None)[source]#

ivy.Container instance method variant of ivy.vander. This method Returns the Vandermonde matrix of the input array.

Parameters:
  • self (Container) – 1-D input array.

  • N (Optional[Union[int, Container]], default: None) – Number of columns in the output. If N is not specified, a square array is returned (N = len(x))

  • increasing (Union[bool, Container], default: False) – Order of the powers of the columns. If True, the powers increase from left to right, if False (the default) they are reversed.

  • out (Optional[Container], default: None) – optional output container, for writing the result to.

Return type:

Container

Returns:

ret – an container containing the Vandermonde matrices of the arrays included in the input container.

Examples

With ivy.Container inputs:

>>> x = ivy.Container(
        a = ivy.array([1, 2, 3, 5])
        b = ivy.array([6, 7, 8, 9])
    )
>>> x.vander()
{
    a: ivy.array(
            [[  1,   1,   1,   1],
            [  8,   4,   2,   1],
            [ 27,   9,   3,   1],
            [125,  25,   5,   1]]
            ),
    b: ivy.array(
            [[216,  36,   6,   1],
            [343,  49,   7,   1],
            [512,  64,   8,   1],
            [729,  81,   9,   1]]
            )
}
vecdot(x2, /, *, axis=-1, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container

vector_norm(*, axis=None, keepdims=False, ord=2, dtype=None, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#

ivy.Container instance method variant of ivy.vector_norm. This method simply wraps the function, and so the docstring for ivy.vector_norm also applies to this method with minimal changes.

Parameters:
  • self (Container) – input array. Should have a floating-point data type.

  • axis (Optional[Union[int, Sequence[int], Container]], default: None) – If an integer, axis specifies the axis (dimension) along which to compute vector norms. If an n-tuple, axis specifies the axes (dimensions) along which to compute batched vector norms. If None, the vector norm must be computed over all array values (i.e., equivalent to computing the vector norm of a flattened array). Negative indices must be supported. Default: None.

  • keepdims (Union[bool, Container], default: False) – If True, the axes (dimensions) specified by axis must be included in the result as singleton dimensions, and, accordingly, the result must be compatible with the input array (see broadcasting).Otherwise, if False, the axes (dimensions) specified by axis must not be included in the result. Default: False.

  • ord (Union[int, float, Literal[inf, -inf], Container], default: 2) –

    order of the norm. The following mathematical norms must be supported:

    ord

    description

    1

    L1-norm (Manhattan)

    2

    L2-norm (Euclidean)

    inf

    infinity norm

    (int,float >= 1)

    p-norm

    The following non-mathematical “norms” must be supported:

    Default: 2.

  • dtype (Optional[Union[Dtype, NativeDtype, Container]], default: None) – data type that may be used to perform the computation more precisely. The input array x gets cast to dtype before the function’s computations.

  • out (Optional[Container], default: None) – optional output array, for writing the result to. It must have a shape that the inputs broadcast to.

Return type:

Container

Returns:

ret – an array containing the vector norms. If axis is None, the returned array must be a zero-dimensional array containing a vector norm. If axis is a scalar value (int or float), the returned array must have a rank which is one less than the rank of x. If axis is a n-tuple, the returned array must have a rank which is n less than the rank of x. The returned array must have a floating-point data type determined by type-promotion.

Examples

>>> x = ivy.Container(a = [1., 2., 3.], b = [-2., 0., 3.2])
>>> y = x.vector_norm()
>>> print(y)
{
    a: ivy.array([3.7416575]),
    b: ivy.array([3.77359247])
}
vector_to_skew_symmetric_matrix(*, key_chains=None, to_apply=True, prune_unapplied=False, map_sequences=False, out=None)[source]#
Return type:

Container