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

79 Views Asked by At

In order to keep my matrices A in sync with my vectors v I want to create

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

However, this gives me a compiler error.

1

There are 1 best solutions below

3
On BEST ANSWER

Domains are initialized with ranges. So you need to build mdom from vdom's ranges, by calling the dim(i) method:

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

It is also a common pattern to define the problem space as a range, and then re-use that variable elsewhere:

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