function power
power(
x: number,
y: number,
): number

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

x: number

The base, can be a number, array, or matrix

y: number

The exponent, can be a number, array, or matrix

Return Type

number

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: number,
y: array,
): array

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

x: number

The base, can be a number, array, or matrix

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: array,
y: number,
): array

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

The base, can be a number, array, or matrix

y: number

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: array,
y: array,
): array

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

The base, can be a number, array, or matrix

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: number,
y: matrix,
): matrix

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

x: number

The base, can be a number, array, or matrix

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: matrix,
y: number,
): matrix

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

The base, can be a number, array, or matrix

y: number

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided

power(
x: matrix,
y: matrix,
): matrix

Element-wise power X .^ Y.

Raises each element of X to the corresponding power in Y. For scalar inputs, performs standard exponentiation.

Examples

Power of two numbers

import { assertEquals } from "jsr:@std/assert";

assertEquals(power(2, 3), 8);

Element-wise power of arrays

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], [2, 2, 2]), [4, 9, 16]);

Array to scalar power

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([2, 3, 4], 2), [4, 9, 16]);

Element-wise power of matrices

import { assertEquals } from "jsr:@std/assert";

assertEquals(power([[2, 3], [4, 5]], [[2, 2], [2, 2]]), [[4, 9], [16, 25]]);

Parameters

The base, can be a number, array, or matrix

The exponent, can be a number, array, or matrix

Return Type

The result of element-wise exponentiation x .^ y

Throws

If the input dimensions do not agree or if no arguments are provided