Skip to content

Latest commit

 

History

History
64 lines (42 loc) · 1.11 KB

ldexp.md

File metadata and controls

64 lines (42 loc) · 1.11 KB

ldexp

Multiply values by powers of two using a separate exponent operand.

API

Numeric.math.ldexp(first, right = 0)

Combines operands with NumPy style broadcast.

  • Parameters:
    • first: Mantissa operand as a scalar, vector, or matrix
    • right: Exponent operand as a scalar, vector, or matrix
  • Returns: Scaled values matching the broadcast shape of the operands
  • NumPy: Equivalent to np.ldexp.

Examples

Scale one value by a power of two

import Numeric from '@neabyte/numerix'

const value = Numeric.math.ldexp(3, 2)

console.log(value)
// 12

Scale a vector by matching exponents

import Numeric from '@neabyte/numerix'

const values = Numeric.math.ldexp([1, 2], [3, 4])

console.log(values)
// [8,32]

Default exponent leaves the value unchanged

import Numeric from '@neabyte/numerix'

const value = Numeric.math.ldexp(3)

console.log(value)
// 3

Rebuild a value from mantissa and exponent

import Numeric from '@neabyte/numerix'

const parts = Numeric.math.frexp(12)
const value = Numeric.math.ldexp(parts[0], parts[1])

console.log(value)
// 12