Skip to content

Latest commit

 

History

History
62 lines (40 loc) · 923 Bytes

square.md

File metadata and controls

62 lines (40 loc) · 923 Bytes

square

Square every element in nested numeric inputs.

API

Numeric.math.square(value)

Applies the square across nested numeric inputs.

  • Parameters:
    • value: Scalar, vector, or matrix input values
  • Returns: Squares matching the input nesting shape
  • NumPy: Equivalent to np.square.

Examples

Square of a scalar

import Numeric from '@neabyte/numerix'

const value = Numeric.math.square(5)

console.log(value)
// 25

Squares of a vector

import Numeric from '@neabyte/numerix'

const values = Numeric.math.square([2, 3])

console.log(values)
// [4,9]

Squares of a matrix

import Numeric from '@neabyte/numerix'

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

console.log(values)
// [[1,4],[9,16]]

Square of a negative value

import Numeric from '@neabyte/numerix'

const value = Numeric.math.square(-5)

console.log(value)
// 25