Home
Getting Started
  • Fundamentals
  • Advanced
  • Fundamentals
  • Intermediate
  • Advanced
OM-Functions
  • FAQs
  • Glossary
  • Contributing
Changelog
Github
Home
Getting Started
  • Fundamentals
  • Advanced
  • Fundamentals
  • Intermediate
  • Advanced
OM-Functions
  • FAQs
  • Glossary
  • Contributing
Changelog
Github
  • OM-Functions

    • OM-Functions Overview
    • Arithmetic Operations
    • Array Operations
    • Logical Operations
    • Statistics
    • Transformations
    • Utilities

Arthimetric Operations

These functions are used to perform arithmetic operations on arrays.

1. mad.add(a, b)

Adds two arrays element-wise:

ParameterTypeDescription
a, bArrayArrays of the same shape
ReturnsArrayResulting array after addition

Example:

import { add } from 'openmadness';

add([1, 2], [3, 4]);
// Result: [4, 6]

2. mad.subtract(a, b)

Subtracts the second array from the first, element-wise:

ParameterTypeDescription
a, bArrayArrays of the same shape
ReturnsArrayResulting array after subtraction

Example:

import { subtract } from 'openmadness';

subtract([5, 6], [2, 3]);
// Result: [3, 3]

3. mad.multiply(a, b)

Multiplies two arrays element-wise:

ParameterTypeDescription
a, bArrayArrays of the same shape
ReturnsArrayResulting array after multiplication

Example:

import { multiply } from 'openmadness';

multiply([2, 3], [4, 5]);
// Result: [8, 15]

4. mad.divide(a, b)

Divides the first array by the second, element-wise:

ParameterTypeDescription
a, bArrayArrays of the same shape
ReturnsArrayResulting array after division

Example:

import { divide } from 'openmadness';

divide([10, 20], [2, 5]);
// Result: [5, 4]

5. mad.pow(a, b)

Raises each element in a to the power of the corresponding element or scalar b:

ParameterTypeDescription
aArrayBase values
bArray or numberExponents
ReturnsArrayArray of exponentiated values

Example:

import { pow } from 'openmadness';

pow([2, 3], 2);
// Result: [4, 9]
Edit this page on GitHub
Last Updated:: 7/11/25, 12:24 PM
Contributors: Dev-Liz
Prev
OM-Functions Overview
Next
Array Operations