matrix identity

For filters.

Create an identity matrix of the given size.

Command Type

built-in

Signature

> matrix identity {flags} (size)

Parameters

  • size: The size of the square identity matrix.

Input/output types:

input output
nothing matrix

Examples

Create a 3x3 identity matrix

> matrix identity 3 | matrix into-nu | to nuon
[[1.0, 0.0, 0.0], [0.0, 1.0, 0.0], [0.0, 0.0, 1.0]]

Create a 2x2 identity matrix

> matrix identity 2 | matrix into-nu | to nuon
[[1.0, 0.0], [0.0, 1.0]]

Ported from nushell/nushell.github.io. Copyright (c) 2021 Nushell Project. MIT License.