MathTop

array_identity 函数

构造方形或矩形的单位样式数组。

语法

  • ArrayTools:-Identity(n)
  • ArrayTools:-Identity([rows, columns])
  • ArrayTools:-Identity(rows, columns)
  • array_identity(dimensions)

参数与选项

n方形单位数组的大小。
rows, columns矩形维度。主对角线元素为 1,其余为 0。

示例

  1. 方形单位数组ArrayTools:-Identity(3)返回 [[1, 0, 0], [0, 1, 0], [0, 0, 1]]。
  2. 矩形单位数组ArrayTools:-Identity([2, 3])返回 [[1, 0, 0], [0, 1, 0]]。