The expand command in Chapel returns a new domain. I would like to increase a domain by one kinda like
var d: domain(1) = {1..5};
writeln(d);
--{1..5}
expand(d)(1);
writeln(d);
--{1..6};
domain
expansion:some worked as documented, some not:
var d: domain(1) = {1..5};
writeln( d ); // SET {1..5}
// {1..5}
var e: domain(1) = d.expand(1);
writeln( e ); // OK, DOMAIN d == {1..5} EXTENDED ON BOTH ENDS INTO {0..6}
// {0..6}
var AonD: [d] int;
AonD.push_back(1);
writeln( AonD.domain ); // OK, DOMAIN EXTENDED INDIRECTLY ON DESIRED END INTO {1..6}
// {1..6}
// var f: domain(1) = {1..5}; // NEW {1..5} - A NON-SHARED, NON-USED ( NON-MAPPED ) DOMAIN
// f.add(6); // FAILS v/s A PROMISE IN: http://chapel.cray.com/docs/master/builtins/internal/ChapelArray.html#ChapelArray.add
// f += 6; // FAILS
// writeln( f );
As of Chapel 1.15 there is no in-place option for the
expand
method on domains. You would need to assign the result ofexpand
to the desired domain:It doesn't sound like
expand
is what you want though, becauseexpand
will grow the domain in both directions in each dimension. To add one index to a rectangular domain, you can assign a domain literal to your domain:For irregular domains you can use the
add
method:Note that you cannot use the
add
method on rectangular domains. This is defined in section 19.8.6 in version 0.983 of the Chapel language specification.