function mpower
mpower(
x: matrix,
y: number,
): matrix

Matrix power X ^ Y.

Raises a square matrix X to the power of a scalar exponent Y.

Examples

Raise a matrix to the power of 3

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

assertEquals(mpower([[1,1,-1],[1,-2,3],[2,3,1]], 3),
  [[-2, 11, -11], [11, -35, 33], [22, 33, -2]]);

Parameters

The base matrix (must be square)

y: number

The exponent (must be a scalar)

Return Type

The resulting matrix after exponentiation

Throws

If the input is not a square matrix or the exponent is not a scalar

Usage

import mpower from "elemop/mpower.ts";