fill_diagonal#

ivy.fill_diagonal(a, v, /, *, wrap=False)[source]#

Fill the main diagonal of the given array of any dimensionality..

Parameters:
  • a (Union[Array, NativeArray]) – Array at least 2D.

  • v (Union[int, float, Array, NativeArray]) – Value(s) to write on the diagonal. If val is scalar, the value is written along the diagonal. If array-like, the flattened val is written along the diagonal, repeating if necessary to fill all diagonal entries.

  • wrap (bool, default: False) – The diagonal ‘wrapped’ after N columns for tall matrices.

Return type:

Union[Array, NativeArray]

Returns:

ret – Array with the diagonal filled.

Array.fill_diagonal(self, v, /, *, wrap=False)[source]#

ivy.Array instance method variant of ivy.fill_diag.

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

Return type:

Array

Container.fill_diagonal(self, v, /, *, wrap=False)[source]#

ivy.Container instance method variant of ivy.fill_diagonal.

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

Return type:

Container