Skip to content

Latest commit

 

History

History
63 lines (41 loc) · 1.13 KB

mul.md

File metadata and controls

63 lines (41 loc) · 1.13 KB

mul

Multiply two operands together using NumPy style broadcasting rules.

API

Numeric.math.mul(first, right = 1)

Combines operands with NumPy style broadcast.

  • Parameters:
    • first: First operand as a scalar, vector, or matrix
    • right: Second operand as a scalar, vector, or matrix
  • Returns: Products matching the broadcast shape of the operands
  • NumPy: Covers np.multiply, np.matvec, np.vecmat through a single Numerix method.

Examples

Multiply two scalars

import Numeric from '@neabyte/numerix'

const product = Numeric.math.mul(3, 4)

console.log(product)
// 12

Multiply a vector by a scalar

import Numeric from '@neabyte/numerix'

const products = Numeric.math.mul([1, 2, 3], 3)

console.log(products)
// [3,6,9]

Multiply two vectors element-wise

import Numeric from '@neabyte/numerix'

const products = Numeric.math.mul([2, 3], [4, 5])

console.log(products)
// [8,15]

Multiply each matrix row by a vector

import Numeric from '@neabyte/numerix'

const products = Numeric.math.mul([[1, 2], [3, 4]], [1, 1])

console.log(products)
// [[1,2],[3,4]]