Chapel中如何提取上三角矩阵w或w/o对角线

How to extract the upper triangular matrix w or w/o diagonal in Chapel

最好的故事从我的矩阵开始 A

var A: [{1..4,1..4}] real = (
  (4, -30, 60, -35),
  (-30, 300, -675, 420),
  (60, -675, 1620, -1050),
  (-35, 420, -1050, 700)
  );

我记得在某个地方你可以得到上三角,但我在 Chapel docs 中找不到它你能把它设置为 in/exclude 对角线吗?

使用 LinearAlgebra 库:

use LinearAlgebra;

var A: [{1..4,1..4}] real = (
  (4, -30, 60, -35),
  (-30, 300, -675, 420),
  (60, -675, 1620, -1050),
  (-35, 420, -1050, 700)
  );

var upperTriangle = triu(A);

// Confirm it worked
writeln(isTriu(upperTriangle));