Go to repository

Function matrix

Creates a two-dimensional matrix where all positions are filled using the given generator.

Error if the width or the height given are zero or negative.

Type Parameters

  • T

Parameters

  • width: number

    The number of rows of the matrix

  • height: number

    The number of columns of the matrix

  • Optional
    initialValueGenerator: ((i: number, j: number) => T)

    A function that given the i,j position of the element returns the element to store the matrix at that position

      • (i, j): T
      • Parameters

        • i: number
        • j: number

        Returns T

Returns T[][]

A T[][] where T is the type of the elements in the matrix.