Skip to content
Snippets Groups Projects

Element Counting in isply

  • Clone with SSH
  • Clone with HTTPS
  • Embed
  • Share
    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)
    0% Loading or .
    You are about to add 0 people to the discussion. Proceed with caution.
    Finish editing this message first!
    Please register or to comment