查找教堂矩阵中的行数或列数
Find the number of rows or columns in a Chapel Matrix
我创建了以下矩阵,我想确定矩阵现在具有的 rows/columns 个数:
module AswanBigMatrix {
use LinearAlgebra;
proc main() {
var A = Matrix(
[0.0, 0.8, 1.1, 0.0, 2.0]
,[0.8, 0.0, 1.3, 1.0, 0.0]
,[1.1, 1.3, 0.0, 0.5, 1.7]
,[0.0, 1.0, 0.5, 0.0, 1.5]
,[2.0, 0.0, 1.7, 1.5, 0.0]
);
}
writeln(A.domain);
}
这个returns{0..4, 0..4}
是有道理的,但是我不能以A.domain[0]
为例求出长度
快到了:
const D = {1..8,1..9};
var Matrix_A: [D] int;
writeln( "Matrix_A[] has a .domain() of [ ",
Matrix_A.domain.dims(), " ], the 1st-dimension being: ",
Matrix_A.domain.dim(1).length()
);
writeln( "Matrix_A[] has a .shape() of ( ",
Matrix_A.shape, " ), ",
"the 1st-dimension being: ",
Matrix_A.shape[1]
);
输出:
Matrix_A[] has a .domain() of [ (1..8, 1..9) ], the 1st-dimension being: 8
Matrix_A[] has a .shape() of ( (8, 9) ), the 1st-dimension being: 8
我创建了以下矩阵,我想确定矩阵现在具有的 rows/columns 个数:
module AswanBigMatrix {
use LinearAlgebra;
proc main() {
var A = Matrix(
[0.0, 0.8, 1.1, 0.0, 2.0]
,[0.8, 0.0, 1.3, 1.0, 0.0]
,[1.1, 1.3, 0.0, 0.5, 1.7]
,[0.0, 1.0, 0.5, 0.0, 1.5]
,[2.0, 0.0, 1.7, 1.5, 0.0]
);
}
writeln(A.domain);
}
这个returns{0..4, 0..4}
是有道理的,但是我不能以A.domain[0]
为例求出长度
快到了:
const D = {1..8,1..9};
var Matrix_A: [D] int;
writeln( "Matrix_A[] has a .domain() of [ ",
Matrix_A.domain.dims(), " ], the 1st-dimension being: ",
Matrix_A.domain.dim(1).length()
);
writeln( "Matrix_A[] has a .shape() of ( ",
Matrix_A.shape, " ), ",
"the 1st-dimension being: ",
Matrix_A.shape[1]
);
输出:
Matrix_A[] has a .domain() of [ (1..8, 1..9) ], the 1st-dimension being: 8
Matrix_A[] has a .shape() of ( (8, 9) ), the 1st-dimension being: 8