matrix scale

For filters.

Multiply all elements of a matrix by a scalar.

Command Type

built-in

Signature

> matrix scale {flags} (scalar)

Parameters

  • scalar: The scalar to multiply each element by.

Input/output types:

input output
matrix matrix

Examples

Scale a matrix by an integer

> matrix identity 2 | matrix scale 3 | matrix into-nu | to nuon
[[3.0, 0.0], [0.0, 3.0]]

Scale a matrix by a float

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

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