Home / Docs / Standard library / Prelude

matrix_diagonal

Release v0.4.0Edition 0.5 preview

A function of the prelude, in scope in every module. Edition 0.5 preview.

una
pub matrix_diagonal[T](values: Array[T]) -> Matrix[T]
  ensures result.rows == values.len and result.columns == values.len

The square matrix with values on its diagonal and +0 of the element type elsewhere (spec/29 §17). O(n²).

Specification

Generated from the standard modules of una v0.4.0 (docs/std/listing.json, which is not part of the specification). The specification governs: spec/14 §1.