repmat<T>(): matrix<T>
Replicate and tile an array or matrix.
Creates a new matrix by repeating the input value, array, or matrix in a tiled fashion.
If only two arguments are provided, m is used for both row and column replication.
Replicate a scalar value into a 3x3 matrix
Replicate a scalar value into a 3x3 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(10, 3), [ [10, 10, 10], [10, 10, 10], [10, 10, 10] ]);
Replicate a scalar into a 3x2 matrix
Replicate a scalar into a 3x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(0.5, 3, 2), [ [0.5, 0.5], [0.5, 0.5], [0.5, 0.5] ]);
Replicate a row vector
Replicate a row vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([5, 6, 3], 1, 2), [ [5, 6, 3, 5, 6, 3] ]);
Replicate a 2x2 matrix
Replicate a 2x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[9, 5], [6, 1]], 2), [ [9, 5, 9, 5], [6, 1, 6, 1], [9, 5, 9, 5], [6, 1, 6, 1] ]);
Replicate a column vector
Replicate a column vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[2], [3]], 2, 3), [ [2, 2, 2], [3, 3, 3], [2, 2, 2], [3, 3, 3] ]);
Single-element matrix repeated
Single-element matrix repeated
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[7]], 2, 2), [ [7, 7], [7, 7] ]);
repmat<T>(): matrix<T>
Replicate and tile an array or matrix.
Creates a new matrix by repeating the input value, array, or matrix in a tiled fashion.
If only two arguments are provided, m is used for both row and column replication.
Replicate a scalar value into a 3x3 matrix
Replicate a scalar value into a 3x3 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(10, 3), [ [10, 10, 10], [10, 10, 10], [10, 10, 10] ]);
Replicate a scalar into a 3x2 matrix
Replicate a scalar into a 3x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(0.5, 3, 2), [ [0.5, 0.5], [0.5, 0.5], [0.5, 0.5] ]);
Replicate a row vector
Replicate a row vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([5, 6, 3], 1, 2), [ [5, 6, 3, 5, 6, 3] ]);
Replicate a 2x2 matrix
Replicate a 2x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[9, 5], [6, 1]], 2), [ [9, 5, 9, 5], [6, 1, 6, 1], [9, 5, 9, 5], [6, 1, 6, 1] ]);
Replicate a column vector
Replicate a column vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[2], [3]], 2, 3), [ [2, 2, 2], [3, 3, 3], [2, 2, 2], [3, 3, 3] ]);
Single-element matrix repeated
Single-element matrix repeated
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[7]], 2, 2), [ [7, 7], [7, 7] ]);
repmat<T>(x: T,m: number,n?: number,): matrix<T>
Replicate and tile an array or matrix.
Creates a new matrix by repeating the input value, array, or matrix in a tiled fashion.
If only two arguments are provided, m is used for both row and column replication.
Replicate a scalar value into a 3x3 matrix
Replicate a scalar value into a 3x3 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(10, 3), [ [10, 10, 10], [10, 10, 10], [10, 10, 10] ]);
Replicate a scalar into a 3x2 matrix
Replicate a scalar into a 3x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat(0.5, 3, 2), [ [0.5, 0.5], [0.5, 0.5], [0.5, 0.5] ]);
Replicate a row vector
Replicate a row vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([5, 6, 3], 1, 2), [ [5, 6, 3, 5, 6, 3] ]);
Replicate a 2x2 matrix
Replicate a 2x2 matrix
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[9, 5], [6, 1]], 2), [ [9, 5, 9, 5], [6, 1, 6, 1], [9, 5, 9, 5], [6, 1, 6, 1] ]);
Replicate a column vector
Replicate a column vector
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[2], [3]], 2, 3), [ [2, 2, 2], [3, 3, 3], [2, 2, 2], [3, 3, 3] ]);
Single-element matrix repeated
Single-element matrix repeated
import { assertEquals } from "jsr:@std/assert"; assertEquals(repmat([[7]], 2, 2), [ [7, 7], [7, 7] ]);
x: T
The value, array, or matrix to replicate.