import type { array, matrix } from "../types"; /** * Transpose a matrix or array. * * Transposes the given matrix or array. If the input is a 1D array, it is treated as a row vector and the result is a column vector. If the input is a matrix, the rows and columns are swapped. * * @param x The input array or matrix to transpose. * @returns The transposed matrix. * * @throws Throws an error if no input is provided. * * @example Transpose a 2x3 matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[5, 6, 5], [7, 8, -1]]), [[5, 7], [6, 8], [5, -1]]); * * ``` * * @example Transpose a 1D array (row vector) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([5, 6, 3]), [[5], [6], [3]]); * * ``` * * @example Transpose a single number (scalar) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose(5), 5); * * ``` * * @example Transpose a square matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); * * ``` */ export default function transpose(x: number): number; /** * Transpose a matrix or array. * * Transposes the given matrix or array. If the input is a 1D array, it is treated as a row vector and the result is a column vector. If the input is a matrix, the rows and columns are swapped. * * @param x The input array or matrix to transpose. * @returns The transposed matrix. * * @throws Throws an error if no input is provided. * * @example Transpose a 2x3 matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[5, 6, 5], [7, 8, -1]]), [[5, 7], [6, 8], [5, -1]]); * * ``` * * @example Transpose a 1D array (row vector) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([5, 6, 3]), [[5], [6], [3]]); * * ``` * * @example Transpose a single number (scalar) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose(5), 5); * * ``` * * @example Transpose a square matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); * * ``` */ export default function transpose(x: array): matrix; /** * Transpose a matrix or array. * * Transposes the given matrix or array. If the input is a 1D array, it is treated as a row vector and the result is a column vector. If the input is a matrix, the rows and columns are swapped. * * @param x The input array or matrix to transpose. * @returns The transposed matrix. * * @throws Throws an error if no input is provided. * * @example Transpose a 2x3 matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[5, 6, 5], [7, 8, -1]]), [[5, 7], [6, 8], [5, -1]]); * * ``` * * @example Transpose a 1D array (row vector) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([5, 6, 3]), [[5], [6], [3]]); * * ``` * * @example Transpose a single number (scalar) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose(5), 5); * * ``` * * @example Transpose a square matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); * * ``` */ export default function transpose(x: matrix): matrix; /** * Transpose a matrix or array. * * Transposes the given matrix or array. If the input is a 1D array, it is treated as a row vector and the result is a column vector. If the input is a matrix, the rows and columns are swapped. * * @param x The input array or matrix to transpose. * @returns The transposed matrix. * * @throws Throws an error if no input is provided. * * @example Transpose a 2x3 matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[5, 6, 5], [7, 8, -1]]), [[5, 7], [6, 8], [5, -1]]); * * ``` * * @example Transpose a 1D array (row vector) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([5, 6, 3]), [[5], [6], [3]]); * * ``` * * @example Transpose a single number (scalar) * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose(5), 5); * * ``` * * @example Transpose a square matrix * ```ts * import { assertEquals } from "jsr:@std/assert"; * * assertEquals(transpose([[1, 2], [3, 4]]), [[1, 3], [2, 4]]); * * ``` */ export default function transpose(x: array | matrix): matrix; //# sourceMappingURL=transpose.d.ts.map