Subtract one operand from another using NumPy style broadcasting rules.
Numeric.math.sub(first, right = 0)Combines operands with NumPy style broadcast.
- Parameters:
first: First operand as a scalar, vector, or matrixright: Second operand as a scalar, vector, or matrix
- Returns: Differences matching the broadcast shape of the operands
- NumPy: Equivalent to
np.subtract.
import Numeric from '@neabyte/numerix'
const difference = Numeric.math.sub(5, 3)
console.log(difference)
// 2import Numeric from '@neabyte/numerix'
const differences = Numeric.math.sub([10, 20], 1)
console.log(differences)
// [9,19]import Numeric from '@neabyte/numerix'
const differences = Numeric.math.sub([10, 20], [1, 2])
console.log(differences)
// [9,18]import Numeric from '@neabyte/numerix'
const differences = Numeric.math.sub([[10, 20], [30, 40]], [1, 2])
console.log(differences)
// [[9,18],[29,38]]