Given some A: [sps]
over a sparse subdomain of a dom: domain(2)
, a slice A[A.domain.dim(1), k]
yields the kth column as a dense 1D-array. How do I retrieve the kth n−1 dimensional slice of a sparse nD-array as a sparse (n-1)D-array?
var nv: int = 8,
D: domain(2) = {1..nv, 1..nv},
SD: sparse subdomain(D),
X: [SD] real;
SD += (1,2); X[1,2] = 1;
SD += (2,3); X[2,3] = 1;
SD += (3,1); X[3,1] = 1;
SD += (3,4); X[3,4] = 1;
SD += (4,5); X[4,5] = 1;
SD += (3,6); X[3,6] = 1;
SD += (6,8); X[6,8] = 1;
writeln(X);
writeln(X[X.domain.dim(1),2]);
returns
1.0
1.0
1.0 1.0 1.0
1.0
1.0
1.0 0.0 0.0 0.0 0.0 0.0 0.0 0.0
The expectation in the case that I succeed in sparse slicing would be a single 1.0
returned with the ability to retrieve this position of that entry by calling writeln()
on slice.domain
.