+
+ def constraints(self):
+ return _isl.basic_set_constraints(self._ptr)
+
+ def _fromisl(self, cls, symbols):
+ constraints = self.constraints()
+ equalities = []
+ inequalities = []
+ co = []
+ eq_string = ""
+ in_string = ""
+ string = ""
+ for constraint in constraints:
+ ls = libisl.isl_basic_set_get_local_space(self)
+ ctx = libisl.isl_local_space_get_ctx(ls)
+ p = libisl.isl_printer_to_str(ctx)
+ if libisl.isl_constraint_is_equality(constraint): #check if equality
+ constant = libisl.isl_constraint_get_constant_val(constraint)
+ const = libisl.isl_printer_print_val(p, constant)
+ const = libisl.isl_printer_get_str(const).decode()
+ const = int(const)
+ libisl.isl_printer_free(p)
+ for symbol in symbols:
+ p = libisl.isl_printer_to_str(ctx)
+ dim = symbols.index(symbol)
+ coefficient = libisl.isl_constraint_get_coefficient_val(constraint, libisl.isl_dim_set, dim)
+ coeff = libisl.isl_printer_print_val(p, coefficient)
+ coeff = libisl.isl_printer_get_str(coeff).decode()
+ coeff = int(coeff)
+ if coeff!=0:
+ co.append('{}{}'.format(coeff, symbols[dim]))
+ for value in co:
+ string += '{}+'.format(value)
+ equalities.append('{}{}==0'.format(string, const))
+ co = []
+ string = ''
+ libisl.isl_printer_free(p)
+ else: #same for inequality
+ constant = libisl.isl_constraint_get_constant_val(constraint)
+ const = libisl.isl_printer_print_val(p, constant)
+ const = libisl.isl_printer_get_str(const).decode()
+ const = int(const)
+ libisl.isl_printer_free(p)
+ for symbol in symbols:
+ p = libisl.isl_printer_to_str(ctx)
+ dim = symbols.index(symbol)
+ coefficient = libisl.isl_constraint_get_coefficient_val(constraint, libisl.isl_dim_set, dim)
+ coeff = libisl.isl_printer_print_val(p, coefficient)
+ coeff = libisl.isl_printer_get_str(coeff).decode()
+ coeff = int(coeff)
+ if coeff!=0:
+ co.append('{}{}'.format(coeff, symbols[dim]))
+ for value in co:
+ string += '{} + '.format(value)
+ inequalities.append('{}{} <= 0'.format(string, const))
+ co = []
+ string = ""
+ libisl.isl_printer_free(p)
+
+ for equations in equalities:
+ eq_string += ' {}'.format(equations)
+ eq_strings = eq_string.split()
+ print(eq_strings)
+
+ for equations in inequalities:
+ in_string += ', {}'.format(equations)
+ print(in_string)
+ if eq_string and in_string:
+ final = '{}, {}'.format(eq_string, in_string)
+ elif eq_string != '':
+ final = '{}'.format(eq_strings)
+ elif in_string != '' :
+ final = '{}'.format(in_string)
+
+
+ return ('{}({!r})'.format(cls.__name__,final))
+