Element Counting in isply
The snippet can be accessed without any authentication.
Authored by
Andreas Klöckner
count.py 598 B
import islpy as isl
a = isl.BasicSet("[n] -> {[i,j]: 0<= i < n and 0<= j < n and j<= i}")
print a
def count(bset):
result = None
for i in range(bset.dim(isl.dim_type.set)):
dmax = bset.dim_max(i)
dmin = bset.dim_min(i)
length = isl.PwQPolynomial.from_pw_aff(dmax - dmin + 1)
print "min %s" % bset.get_dim_name(isl.dim_type.set, i), dmin
print "max %s" % bset.get_dim_name(isl.dim_type.set, i), dmax
if result is None:
result = length
else:
result = result.mul(length)
return result
print count(a)
Please register or sign in to comment