ml-matrix
    Preparing search index...

    Class MatrixRowSelectionView

    Hierarchy (View Summary)

    Index

    Constructors

    Properties

    Methods

    [iterator] abs acos acosh add addColumnVector addRowVector and apply asin asinh atan atanh cbrt ceil center clone clz32 cos cosh cumulativeSum diag diagonal div divColumnVector divide divRowVector dot echelonForm entries exp expm1 fill flipColumns flipRows floor fround get getColumn getColumnVector getRow getRowVector gram isColumnVector isDistance isEchelonForm isEmpty isReducedEchelonForm isRowVector isSquare isSymmetric isVector kroneckerProduct kroneckerSum leftShift log log10 log1p log2 max maxColumn maxColumnIndex maxIndex maxRow maxRowIndex mean min minColumn minColumnIndex minIndex minRow minRowIndex mmul mmulByTranspose mmulStrassen mod modulus mpow mul mulColumn mulColumnVector mulRow mulRowVector multiply neg negate norm not or pow product reducedEchelonForm repeat rightShift round scale scaleColumns scaleRows selection set setColumn setRow setSubMatrix sign signPropagatingRightShift sin sinh sortColumns sortRows sqrt standardDeviation strassen2x2 strassen3x3 sub subColumnVector subMatrix subMatrixColumn subMatrixRow subRowVector subtract sum swapColumns swapRows tan tanh tensorProduct to1DArray to2DArray toJSON toString trace transpose trunc values variance xor zeroFillRightShift abs acos acosh add and asin asinh atan atanh cbrt ceil checkMatrix clz32 columnVector copy cos cosh diag diagonal div divide exp expm1 eye floor from1DArray fround identity isMatrix leftShift log log10 log1p log2 max min mod modulus mul multiply not ones or pow rand randInt random rightShift round rowVector sign signPropagatingRightShift sin sinh sqrt sub subtract tan tanh trunc xor zeroFillRightShift zeros

    Constructors

    Properties

    columns: number

    Number of columns of the matrix.

    rows: number

    Number of rows of the matrix.

    size: number

    Total number of elements in the matrix.

    Methods

    • iterator from left to right, from top to bottom yield [row, column, value]

      Returns Generator<[row: number, column: number, value: number], void, void>

    • Applies a callback for each element of the matrix. The function is called in the matrix (this) context.

      Parameters

      • callback: (row: number, column: number) => void

        Function that will be called for each element in the matrix.

      Returns this

    • iterator from left to right, from top to bottom yield [row, column, value]

      Returns Generator<[row: number, column: number, value: number], void, void>

    • Fills the matrix with a given value. All elements will be set to this value.

      Parameters

      • value: number

        New value.

      Returns this

    • Returns the value of the given element of the matrix.

      Parameters

      • rowIndex: number

        Index of the element's row.

      • columnIndex: number

        Index of the element's column.

      Returns number

      • The value of the element.
    • Returns a new array with the values from the given column index.

      Parameters

      • index: number

        Column index.

      Returns number[]

    • Returns a new array with the values from the given row index.

      Parameters

      • index: number

        Row index.

      Returns number[]

    • Returns the Gram matrix thisᵀ · this (the columns × columns matrix of the dot products of every pair of columns). The result is symmetric, so only its upper triangle is computed and mirrored, and the transpose is never materialized, making it about twice as fast as this.transpose().mmul(this) on dense matrices and much faster on sparse ones (zero entries are skipped). For finite inputs the result is identical to this.transpose().mmul(this).

      Returns Matrix

    • Returns the maximum value of the matrix.

      Returns number

    • Returns the maximum value by the given dimension.

      Parameters

      • by: MatrixDimension

        max by 'row' or 'column'.

      Returns number[]

    • Returns the maximum value of one column.

      Parameters

      • column: number

        Column index.

      Returns number

    • Returns the index of the maximum value of one column.

      Parameters

      • column: number

        Column index.

      Returns [number, number]

    • Returns the index of the maximum value of one row.

      Parameters

      • row: number

        Row index.

      Returns [number, number]

    • Returns the mean of all elements of the matrix.

      Returns number

    • Returns the mean by the given dimension.

      Parameters

      • by: MatrixDimension

        mean by 'row' or 'column'.

      Returns number[]

    • Returns the minimum value of the matrix.

      Returns number

    • Returns the minimum value by the given dimension.

      Parameters

      • by: MatrixDimension

        min by 'row' or 'column'.

      Returns number[]

    • Returns the minimum value of one column.

      Parameters

      • column: number

        Column index.

      Returns number

    • Returns the index of the minimum value of one column.

      Parameters

      • column: number

        Column index.

      Returns [number, number]

    • Returns the index of the maximum value of one row.

      Parameters

      • row: number

        Row index.

      Returns [number, number]

    • Returns the matrix product between this and its transpose (this · thisᵀ), optionally weighting each column by scale (this · diag(scale) · thisᵀ). The result is symmetric, so only its upper triangle is computed and mirrored and the transpose is never materialized, making it about twice as fast as this.mmul(this.transpose()).

      Parameters

      • Optionalscale: ArrayLike<number>

        Optional per-column factors (length equal to the number of columns).

      Returns Matrix

    • Returns the square matrix raised to the given power

      Parameters

      • scalar: number

        the non-negative integer power to raise this matrix to

      Returns Matrix

    • Multiplies the values of a column with a scalar.

      Parameters

      • index: number

        Column index.

      • value: number

      Returns this

    • Multiplies the values of a row with a scalar.

      Parameters

      • index: number

        Row index.

      • value: number

      Returns this

    • Returns the norm of a matrix.

      Parameters

      • Optionaltype: "max" | "frobenius"

        Norm type. Default: 'frobenius'.

      Returns number

    • Returns the product of all elements of the matrix.

      Returns number

    • Returns the product by the given dimension.

      Parameters

      • by: MatrixDimension

        product by 'row' or 'column'.

      Returns number[]

    • Creates a new matrix that is a repetition of the current matrix. New matrix has rows times the number of rows of the original matrix, and columns times the number of columns of the original matrix.

      Parameters

      Returns Matrix

      var matrix = new Matrix([[1, 2]]);
      matrix.repeat({ rows: 2 }); // [[1, 2], [1, 2]]
    • Return a new matrix based on a selection of rows and columns. Order of the indices matters and the same index can be used more than once.

      Parameters

      • rowIndices: ArrayLike<number>

        The row indices to select.

      • columnIndices: ArrayLike<number>

        The column indices to select.

      Returns Matrix

    • Sets a given element of the matrix.

      Parameters

      • rowIndex: number

        Index of the element's row.

      • columnIndex: number

        Index of the element's column.

      • value: number

        The new value for the element.

      Returns this

    • Set a part of the matrix to the given sub-matrix.

      Parameters

      • matrix: MaybeMatrix

        The source matrix from which to extract values.

      • startRow: number

        The index of the first row to set.

      • startColumn: number

        The index of the first column to set.

      Returns this

    • Sorts the columns in-place.

      Parameters

      • OptionalcompareFunction: (a: number, b: number) => number

      Returns this

    • Sorts the rows in-place.

      Parameters

      • OptionalcompareFunction: (a: number, b: number) => number

      Returns this

    • Returns a subset of the matrix.

      Parameters

      • startRow: number

        First row index.

      • endRow: number

        Last row index.

      • startColumn: number

        First column index.

      • endColumn: number

        Last column index.

      Returns Matrix

    • Returns a subset of the matrix based on an array of column indices.

      Parameters

      • indices: ArrayLike<number>

        Array containing the column indices.

      • OptionalstartRow: number

        First row index. Default: 0.

      • OptionalendRow: number

        Last row index. Default: this.rows - 1.

      Returns Matrix

    • Returns a subset of the matrix based on an array of row indices.

      Parameters

      • indices: ArrayLike<number>

        Array containing the row indices.

      • OptionalstartColumn: number

        First column index. Default: 0.

      • OptionalendColumn: number

        Last column index. Default: this.columns - 1.

      Returns Matrix

    • Returns the sum of all elements of the matrix.

      Returns number

    • Returns the sum by the given dimension.

      Parameters

      • by: MatrixDimension

        sum by 'row' or 'column'.

      Returns number[]

    • Swap two columns.

      Parameters

      • column1: number

        First column index.

      • column2: number

        Second column index.

      Returns this

    • Swap two rows.

      Parameters

      • row1: number

        First row index.

      • row2: number

        Second row index.

      Returns this

    • iterator from left to right, from top to bottom yield value

      Returns Generator<number, void, void>

    • Creates a column vector, a matrix with only one column.

      Parameters

      • newData: ArrayLike<number>

        A 1D array containing data for the vector.

      Returns Matrix

      The new matrix.

    • Creates a diagonal matrix based on the given array.

      Parameters

      • data: ArrayLike<number>

        Array containing the data for the diagonal.

      • Optionalrows: number

        Number of rows. Default: data.length.

      • Optionalcolumns: number

        Number of columns. Default: rows.

      Returns Matrix

      • The new diagonal matrix.
    • Creates an identity matrix with the given dimension. Values of the diagonal will be 1 and others will be 0.

      Parameters

      • rows: number

        Number of rows.

      • Optionalcolumns: number

        Number of columns. Default: rows.

      • Optionalvalue: number

        Value to fill the diagonal with. Default: 1.

      Returns Matrix

      • The new identity matrix.
    • Constructs a matrix with the chosen dimensions from a 1D array.

      Parameters

      • newRows: number

        Number of rows.

      • newColumns: number

        Number of columns.

      • newData: ArrayLike<number>

        A 1D array containing data for the matrix.

      Returns Matrix

      The new matrix.

    • Returns a matrix whose elements are the maximum between matrix1 and matrix2.

      Parameters

      • matrix1: MaybeMatrix
      • matrix2: MaybeMatrix

      Returns Matrix

    • Returns a matrix whose elements are the minimum between matrix1 and matrix2.

      Parameters

      • matrix1: MaybeMatrix
      • matrix2: MaybeMatrix

      Returns Matrix

    • Creates a row vector, a matrix with only one row.

      Parameters

      • newData: ArrayLike<number>

        A 1D array containing data for the vector.

      Returns Matrix

      The new matrix.

    • Creates a matrix with the given dimensions. Values will be set to zero. This is equivalent to calling the Matrix constructor.

      Type Parameters

      Parameters

      • rows: number

        Number of rows.

      • columns: number

        Number of columns.

      Returns _M

      The new matrix.