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

Checks if the input is a row vector.

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

Examples

Valid row vector

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

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

Column vector (not a row vector)

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

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

Row vector with multiple columns

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

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

Square matrix (not a row vector)

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

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

Single-element row vector

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

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

Invalid input (not a matrix)

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

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

Empty matrix (should throw an error)

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

assertThrows(() => isrow([]), "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 row vector, otherwise false.

Throws

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