rStats.js v1.3.0
    Preparing search index...

    Function crossprod

    • Matrix cross-product t(x) %*% y, or t(x) %*% x when y is omitted. Equivalent to R's crossprod().

      A vector argument is treated as a one-column matrix.

      Parameters

      • x: VectorOrMatrix

        A matrix (array of rows) or a vector.

      • Optionaly: VectorOrMatrix

        A matrix or a vector with the same number of rows as x. Defaults to x.

      Returns number[][]

      The product as an array of rows (ncol(x) x ncol(y)).

      crossprod([[1, 2], [3, 4]]);         // [[10, 14], [14, 20]]
      crossprod([[1, 2], [3, 4]], [1, 1]); // [[4], [6]]