MathTop

random_matrix 函数

构造由伪随机整数元素组成的矩阵。

语法

  • LinearAlgebra:-RandomMatrix(rows, cols, range = a..b, seed = n)
  • RandomMatrix(rows, cols)
  • random_matrix(rows, cols)

参数与选项

rows正行数。
cols可选正列数。
range可选整数元素范围。
seed可选种子,用于得到可复现示例。

示例

  1. 带种子的随机矩阵LinearAlgebra:-RandomMatrix(2, 3, range = 1..5, seed = 7)返回 [[3, 2, 4], [1, 1, 5]]。