function iscolumn
iscolumn(x: unknown): x is matrix

Checks if the input is a column vector.

Returns true if the input matrix is a column vector, meaning it has more than one row and exactly one column.

Examples

Valid column vector

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

assertEquals(iscolumn([[2], [2]]), true);

Row vector (not a column vector)

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

assertEquals(iscolumn([[2, 2]]), false);

Column vector with multiple rows

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

assertEquals(iscolumn([[1], [2], [3]]), true);

Square matrix (not a column vector)

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

assertEquals(iscolumn([[1, 2], [3, 4]]), false);

Single-element column vector

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

assertEquals(iscolumn([[1]]), true);

Invalid input (not a matrix)

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

assertThrows(() => iscolumn(5), "Input must be a non-empty matrix");

Empty matrix (should throw an error)

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

assertThrows(() => iscolumn([]), "Input must be a non-empty matrix");

Parameters

x: unknown

The input matrix to check.

Return Type

x is matrix

Returns true if x is a column vector, otherwise false.

Throws

If the input is not a valid matrix or if no argument is provided.