如何在 Chapel 中从一维域创建二维域

How to make a 2D domain from 1D domains in Chapel

为了让我的矩阵A与我的向量同步v我想创建

var vdom: domain(1) = {1...10},
    mdom: domain(2) = {odom, odom};

但是,这给了我一个编译器错误。

域使用 ranges. So you need to build mdom from vdom's ranges, by calling the dim(i) 方法初始化:

var vdom: domain(1) = {1...10},
    mdom: domain(2) = {odom.dim(1), odom.dim(1)};

将问题 space 定义为范围,然后在其他地方重新使用该变量也是一种常见的模式:

const vectorSpace = 1..10;
var vdom = {vectorSpace},
    mdom = {vectorSpace, vectorSpace};