random_matrix 函数
构造由伪随机整数元素组成的矩阵。
语法
LinearAlgebra:-RandomMatrix(rows, cols, range = a..b, seed = n)RandomMatrix(rows, cols)random_matrix(rows, cols)
参数与选项
rows | 正行数。 |
|---|---|
cols | 可选正列数。 |
range | 可选整数元素范围。 |
seed | 可选种子,用于得到可复现示例。 |
示例
- 带种子的随机矩阵
LinearAlgebra:-RandomMatrix(2, 3, range = 1..5, seed = 7)返回 [[3, 2, 4], [1, 1, 5]]。