MCPcopy Index your code
hub / github.com/TheAlgorithms/Python / random_matrix

Function random_matrix

linear_algebra/src/lib.py:435–444  ·  view source on GitHub ↗

returns a random matrix WxH with integer components between 'a' and 'b'

(width: int, height: int, a: int, b: int)

Source from the content-addressed store, hash-verified

433
434
435def random_matrix(width: int, height: int, a: int, b: int) -> Matrix:
436 """
437 returns a random matrix WxH with integer components
438 between 'a' and 'b'
439 """
440 random.seed(None)
441 matrix: list[list[float]] = [
442 [random.randint(a, b) for _ in range(width)] for _ in range(height)
443 ]
444 return Matrix(matrix, width, height)

Callers

nothing calls this directly

Calls 1

MatrixClass · 0.70

Tested by

no test coverage detected