1from ctypes import * 2 3isl = cdll.LoadLibrary("libisl.so") 4libc = cdll.LoadLibrary("libc.so.6") 5 6class Error(Exception): 7 pass 8 9class Context: 10 defaultInstance = None 11 12 def __init__(self): 13 ptr = isl.isl_ctx_alloc() 14 self.ptr = ptr 15 16 def __del__(self): 17 isl.isl_ctx_free(self) 18 19 def from_param(self): 20 return self.ptr 21 22 @staticmethod 23 def getDefaultInstance(): 24 if Context.defaultInstance == None: 25 Context.defaultInstance = Context() 26 return Context.defaultInstance 27 28isl.isl_ctx_alloc.restype = c_void_p 29isl.isl_ctx_free.argtypes = [Context] 30 31class union_map: 32 def __init__(self, *args, **keywords): 33 if "ptr" in keywords: 34 self.ctx = keywords["ctx"] 35 self.ptr = keywords["ptr"] 36 return 37 if len(args) == 1 and args[0].__class__ is basic_map: 38 self.ctx = Context.getDefaultInstance() 39 self.ptr = isl.isl_union_map_from_basic_map(isl.isl_basic_map_copy(args[0].ptr)) 40 return 41 if len(args) == 1 and args[0].__class__ is map: 42 self.ctx = Context.getDefaultInstance() 43 self.ptr = isl.isl_union_map_from_map(isl.isl_map_copy(args[0].ptr)) 44 return 45 if len(args) == 1 and type(args[0]) == str: 46 self.ctx = Context.getDefaultInstance() 47 self.ptr = isl.isl_union_map_read_from_str(self.ctx, args[0]) 48 return 49 raise Error 50 def __del__(self): 51 if hasattr(self, 'ptr'): 52 isl.isl_union_map_free(self.ptr) 53 def __str__(self): 54 ptr = isl.isl_union_map_to_str(self.ptr) 55 res = str(cast(ptr, c_char_p).value) 56 libc.free(ptr) 57 return res 58 def __repr__(self): 59 return 'isl.union_map("%s")' % str(self) 60 def polyhedral_hull(arg0): 61 try: 62 if not arg0.__class__ is union_map: 63 arg0 = union_map(arg0) 64 except: 65 raise 66 res = isl.isl_union_map_polyhedral_hull(isl.isl_union_map_copy(arg0.ptr)) 67 return union_map(ctx=arg0.ctx, ptr=res) 68 def coalesce(arg0): 69 try: 70 if not arg0.__class__ is union_map: 71 arg0 = union_map(arg0) 72 except: 73 raise 74 res = isl.isl_union_map_coalesce(isl.isl_union_map_copy(arg0.ptr)) 75 return union_map(ctx=arg0.ctx, ptr=res) 76 def lexmin(arg0): 77 try: 78 if not arg0.__class__ is union_map: 79 arg0 = union_map(arg0) 80 except: 81 raise 82 res = isl.isl_union_map_lexmin(isl.isl_union_map_copy(arg0.ptr)) 83 return union_map(ctx=arg0.ctx, ptr=res) 84 def lexmax(arg0): 85 try: 86 if not arg0.__class__ is union_map: 87 arg0 = union_map(arg0) 88 except: 89 raise 90 res = isl.isl_union_map_lexmax(isl.isl_union_map_copy(arg0.ptr)) 91 return union_map(ctx=arg0.ctx, ptr=res) 92 def union(arg0, arg1): 93 try: 94 if not arg0.__class__ is union_map: 95 arg0 = union_map(arg0) 96 except: 97 raise 98 try: 99 if not arg1.__class__ is union_map: 100 arg1 = union_map(arg1) 101 except: 102 raise 103 res = isl.isl_union_map_union(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 104 return union_map(ctx=arg0.ctx, ptr=res) 105 def subtract(arg0, arg1): 106 try: 107 if not arg0.__class__ is union_map: 108 arg0 = union_map(arg0) 109 except: 110 raise 111 try: 112 if not arg1.__class__ is union_map: 113 arg1 = union_map(arg1) 114 except: 115 raise 116 res = isl.isl_union_map_subtract(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 117 return union_map(ctx=arg0.ctx, ptr=res) 118 def intersect(arg0, arg1): 119 try: 120 if not arg0.__class__ is union_map: 121 arg0 = union_map(arg0) 122 except: 123 raise 124 try: 125 if not arg1.__class__ is union_map: 126 arg1 = union_map(arg1) 127 except: 128 raise 129 res = isl.isl_union_map_intersect(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 130 return union_map(ctx=arg0.ctx, ptr=res) 131 def affine_hull(arg0): 132 try: 133 if not arg0.__class__ is union_map: 134 arg0 = union_map(arg0) 135 except: 136 raise 137 res = isl.isl_union_map_affine_hull(isl.isl_union_map_copy(arg0.ptr)) 138 return union_map(ctx=arg0.ctx, ptr=res) 139 def intersect_params(arg0, arg1): 140 try: 141 if not arg0.__class__ is union_map: 142 arg0 = union_map(arg0) 143 except: 144 raise 145 try: 146 if not arg1.__class__ is set: 147 arg1 = set(arg1) 148 except: 149 raise 150 res = isl.isl_union_map_intersect_params(isl.isl_union_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 151 return union_map(ctx=arg0.ctx, ptr=res) 152 def gist(arg0, arg1): 153 try: 154 if not arg0.__class__ is union_map: 155 arg0 = union_map(arg0) 156 except: 157 raise 158 try: 159 if not arg1.__class__ is union_map: 160 arg1 = union_map(arg1) 161 except: 162 raise 163 res = isl.isl_union_map_gist(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 164 return union_map(ctx=arg0.ctx, ptr=res) 165 def gist_params(arg0, arg1): 166 try: 167 if not arg0.__class__ is union_map: 168 arg0 = union_map(arg0) 169 except: 170 raise 171 try: 172 if not arg1.__class__ is set: 173 arg1 = set(arg1) 174 except: 175 raise 176 res = isl.isl_union_map_gist_params(isl.isl_union_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 177 return union_map(ctx=arg0.ctx, ptr=res) 178 def gist_domain(arg0, arg1): 179 try: 180 if not arg0.__class__ is union_map: 181 arg0 = union_map(arg0) 182 except: 183 raise 184 try: 185 if not arg1.__class__ is union_set: 186 arg1 = union_set(arg1) 187 except: 188 raise 189 res = isl.isl_union_map_gist_domain(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 190 return union_map(ctx=arg0.ctx, ptr=res) 191 def gist_range(arg0, arg1): 192 try: 193 if not arg0.__class__ is union_map: 194 arg0 = union_map(arg0) 195 except: 196 raise 197 try: 198 if not arg1.__class__ is union_set: 199 arg1 = union_set(arg1) 200 except: 201 raise 202 res = isl.isl_union_map_gist_range(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 203 return union_map(ctx=arg0.ctx, ptr=res) 204 def intersect_domain(arg0, arg1): 205 try: 206 if not arg0.__class__ is union_map: 207 arg0 = union_map(arg0) 208 except: 209 raise 210 try: 211 if not arg1.__class__ is union_set: 212 arg1 = union_set(arg1) 213 except: 214 raise 215 res = isl.isl_union_map_intersect_domain(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 216 return union_map(ctx=arg0.ctx, ptr=res) 217 def intersect_range(arg0, arg1): 218 try: 219 if not arg0.__class__ is union_map: 220 arg0 = union_map(arg0) 221 except: 222 raise 223 try: 224 if not arg1.__class__ is union_set: 225 arg1 = union_set(arg1) 226 except: 227 raise 228 res = isl.isl_union_map_intersect_range(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 229 return union_map(ctx=arg0.ctx, ptr=res) 230 def subtract_domain(arg0, arg1): 231 try: 232 if not arg0.__class__ is union_map: 233 arg0 = union_map(arg0) 234 except: 235 raise 236 try: 237 if not arg1.__class__ is union_set: 238 arg1 = union_set(arg1) 239 except: 240 raise 241 res = isl.isl_union_map_subtract_domain(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 242 return union_map(ctx=arg0.ctx, ptr=res) 243 def subtract_range(arg0, arg1): 244 try: 245 if not arg0.__class__ is union_map: 246 arg0 = union_map(arg0) 247 except: 248 raise 249 try: 250 if not arg1.__class__ is union_set: 251 arg1 = union_set(arg1) 252 except: 253 raise 254 res = isl.isl_union_map_subtract_range(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 255 return union_map(ctx=arg0.ctx, ptr=res) 256 def apply_domain(arg0, arg1): 257 try: 258 if not arg0.__class__ is union_map: 259 arg0 = union_map(arg0) 260 except: 261 raise 262 try: 263 if not arg1.__class__ is union_map: 264 arg1 = union_map(arg1) 265 except: 266 raise 267 res = isl.isl_union_map_apply_domain(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 268 return union_map(ctx=arg0.ctx, ptr=res) 269 def apply_range(arg0, arg1): 270 try: 271 if not arg0.__class__ is union_map: 272 arg0 = union_map(arg0) 273 except: 274 raise 275 try: 276 if not arg1.__class__ is union_map: 277 arg1 = union_map(arg1) 278 except: 279 raise 280 res = isl.isl_union_map_apply_range(isl.isl_union_map_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 281 return union_map(ctx=arg0.ctx, ptr=res) 282 def reverse(arg0): 283 try: 284 if not arg0.__class__ is union_map: 285 arg0 = union_map(arg0) 286 except: 287 raise 288 res = isl.isl_union_map_reverse(isl.isl_union_map_copy(arg0.ptr)) 289 return union_map(ctx=arg0.ctx, ptr=res) 290 def detect_equalities(arg0): 291 try: 292 if not arg0.__class__ is union_map: 293 arg0 = union_map(arg0) 294 except: 295 raise 296 res = isl.isl_union_map_detect_equalities(isl.isl_union_map_copy(arg0.ptr)) 297 return union_map(ctx=arg0.ctx, ptr=res) 298 def deltas(arg0): 299 try: 300 if not arg0.__class__ is union_map: 301 arg0 = union_map(arg0) 302 except: 303 raise 304 res = isl.isl_union_map_deltas(isl.isl_union_map_copy(arg0.ptr)) 305 return union_set(ctx=arg0.ctx, ptr=res) 306 def is_empty(arg0): 307 try: 308 if not arg0.__class__ is union_map: 309 arg0 = union_map(arg0) 310 except: 311 raise 312 res = isl.isl_union_map_is_empty(arg0.ptr) 313 return res 314 def is_single_valued(arg0): 315 try: 316 if not arg0.__class__ is union_map: 317 arg0 = union_map(arg0) 318 except: 319 raise 320 res = isl.isl_union_map_is_single_valued(arg0.ptr) 321 return res 322 def is_injective(arg0): 323 try: 324 if not arg0.__class__ is union_map: 325 arg0 = union_map(arg0) 326 except: 327 raise 328 res = isl.isl_union_map_is_injective(arg0.ptr) 329 return res 330 def is_bijective(arg0): 331 try: 332 if not arg0.__class__ is union_map: 333 arg0 = union_map(arg0) 334 except: 335 raise 336 res = isl.isl_union_map_is_bijective(arg0.ptr) 337 return res 338 def is_subset(arg0, arg1): 339 try: 340 if not arg0.__class__ is union_map: 341 arg0 = union_map(arg0) 342 except: 343 raise 344 try: 345 if not arg1.__class__ is union_map: 346 arg1 = union_map(arg1) 347 except: 348 raise 349 res = isl.isl_union_map_is_subset(arg0.ptr, arg1.ptr) 350 return res 351 def is_equal(arg0, arg1): 352 try: 353 if not arg0.__class__ is union_map: 354 arg0 = union_map(arg0) 355 except: 356 raise 357 try: 358 if not arg1.__class__ is union_map: 359 arg1 = union_map(arg1) 360 except: 361 raise 362 res = isl.isl_union_map_is_equal(arg0.ptr, arg1.ptr) 363 return res 364 def is_strict_subset(arg0, arg1): 365 try: 366 if not arg0.__class__ is union_map: 367 arg0 = union_map(arg0) 368 except: 369 raise 370 try: 371 if not arg1.__class__ is union_map: 372 arg1 = union_map(arg1) 373 except: 374 raise 375 res = isl.isl_union_map_is_strict_subset(arg0.ptr, arg1.ptr) 376 return res 377 def foreach_map(arg0, arg1): 378 try: 379 if not arg0.__class__ is union_map: 380 arg0 = union_map(arg0) 381 except: 382 raise 383 exc_info = [None] 384 fn = CFUNCTYPE(c_int, c_void_p, c_void_p) 385 def cb_func(cb_arg0, cb_arg1): 386 cb_arg0 = map(ctx=arg0.ctx, ptr=cb_arg0) 387 try: 388 arg1(cb_arg0) 389 except: 390 import sys 391 exc_info[0] = sys.exc_info() 392 return -1 393 return 0 394 cb = fn(cb_func) 395 res = isl.isl_union_map_foreach_map(arg0.ptr, cb, None) 396 if exc_info[0] != None: 397 raise exc_info[0][0], exc_info[0][1], exc_info[0][2] 398 return res 399 400isl.isl_union_map_from_basic_map.restype = c_void_p 401isl.isl_union_map_from_basic_map.argtypes = [c_void_p] 402isl.isl_union_map_from_map.restype = c_void_p 403isl.isl_union_map_from_map.argtypes = [c_void_p] 404isl.isl_union_map_read_from_str.restype = c_void_p 405isl.isl_union_map_read_from_str.argtypes = [Context, c_char_p] 406isl.isl_union_map_polyhedral_hull.restype = c_void_p 407isl.isl_union_map_coalesce.restype = c_void_p 408isl.isl_union_map_lexmin.restype = c_void_p 409isl.isl_union_map_lexmax.restype = c_void_p 410isl.isl_union_map_union.restype = c_void_p 411isl.isl_union_map_subtract.restype = c_void_p 412isl.isl_union_map_intersect.restype = c_void_p 413isl.isl_union_map_affine_hull.restype = c_void_p 414isl.isl_union_map_intersect_params.restype = c_void_p 415isl.isl_union_map_gist.restype = c_void_p 416isl.isl_union_map_gist_params.restype = c_void_p 417isl.isl_union_map_gist_domain.restype = c_void_p 418isl.isl_union_map_gist_range.restype = c_void_p 419isl.isl_union_map_intersect_domain.restype = c_void_p 420isl.isl_union_map_intersect_range.restype = c_void_p 421isl.isl_union_map_subtract_domain.restype = c_void_p 422isl.isl_union_map_subtract_range.restype = c_void_p 423isl.isl_union_map_apply_domain.restype = c_void_p 424isl.isl_union_map_apply_range.restype = c_void_p 425isl.isl_union_map_reverse.restype = c_void_p 426isl.isl_union_map_detect_equalities.restype = c_void_p 427isl.isl_union_map_deltas.restype = c_void_p 428isl.isl_union_map_free.argtypes = [c_void_p] 429isl.isl_union_map_to_str.argtypes = [c_void_p] 430isl.isl_union_map_to_str.restype = POINTER(c_char) 431 432class map(union_map): 433 def __init__(self, *args, **keywords): 434 if "ptr" in keywords: 435 self.ctx = keywords["ctx"] 436 self.ptr = keywords["ptr"] 437 return 438 if len(args) == 1 and type(args[0]) == str: 439 self.ctx = Context.getDefaultInstance() 440 self.ptr = isl.isl_map_read_from_str(self.ctx, args[0]) 441 return 442 if len(args) == 1 and args[0].__class__ is basic_map: 443 self.ctx = Context.getDefaultInstance() 444 self.ptr = isl.isl_map_from_basic_map(isl.isl_basic_map_copy(args[0].ptr)) 445 return 446 raise Error 447 def __del__(self): 448 if hasattr(self, 'ptr'): 449 isl.isl_map_free(self.ptr) 450 def __str__(self): 451 ptr = isl.isl_map_to_str(self.ptr) 452 res = str(cast(ptr, c_char_p).value) 453 libc.free(ptr) 454 return res 455 def __repr__(self): 456 return 'isl.map("%s")' % str(self) 457 def lexmin(arg0): 458 try: 459 if not arg0.__class__ is map: 460 arg0 = map(arg0) 461 except: 462 raise 463 res = isl.isl_map_lexmin(isl.isl_map_copy(arg0.ptr)) 464 return map(ctx=arg0.ctx, ptr=res) 465 def lexmax(arg0): 466 try: 467 if not arg0.__class__ is map: 468 arg0 = map(arg0) 469 except: 470 raise 471 res = isl.isl_map_lexmax(isl.isl_map_copy(arg0.ptr)) 472 return map(ctx=arg0.ctx, ptr=res) 473 def reverse(arg0): 474 try: 475 if not arg0.__class__ is map: 476 arg0 = map(arg0) 477 except: 478 raise 479 res = isl.isl_map_reverse(isl.isl_map_copy(arg0.ptr)) 480 return map(ctx=arg0.ctx, ptr=res) 481 def union(arg0, arg1): 482 try: 483 if not arg0.__class__ is map: 484 arg0 = map(arg0) 485 except: 486 raise 487 try: 488 if not arg1.__class__ is map: 489 arg1 = map(arg1) 490 except: 491 return union_map(arg0).union(arg1) 492 res = isl.isl_map_union(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 493 return map(ctx=arg0.ctx, ptr=res) 494 def intersect_domain(arg0, arg1): 495 try: 496 if not arg0.__class__ is map: 497 arg0 = map(arg0) 498 except: 499 raise 500 try: 501 if not arg1.__class__ is set: 502 arg1 = set(arg1) 503 except: 504 return union_map(arg0).intersect_domain(arg1) 505 res = isl.isl_map_intersect_domain(isl.isl_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 506 return map(ctx=arg0.ctx, ptr=res) 507 def intersect_range(arg0, arg1): 508 try: 509 if not arg0.__class__ is map: 510 arg0 = map(arg0) 511 except: 512 raise 513 try: 514 if not arg1.__class__ is set: 515 arg1 = set(arg1) 516 except: 517 return union_map(arg0).intersect_range(arg1) 518 res = isl.isl_map_intersect_range(isl.isl_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 519 return map(ctx=arg0.ctx, ptr=res) 520 def apply_domain(arg0, arg1): 521 try: 522 if not arg0.__class__ is map: 523 arg0 = map(arg0) 524 except: 525 raise 526 try: 527 if not arg1.__class__ is map: 528 arg1 = map(arg1) 529 except: 530 return union_map(arg0).apply_domain(arg1) 531 res = isl.isl_map_apply_domain(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 532 return map(ctx=arg0.ctx, ptr=res) 533 def apply_range(arg0, arg1): 534 try: 535 if not arg0.__class__ is map: 536 arg0 = map(arg0) 537 except: 538 raise 539 try: 540 if not arg1.__class__ is map: 541 arg1 = map(arg1) 542 except: 543 return union_map(arg0).apply_range(arg1) 544 res = isl.isl_map_apply_range(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 545 return map(ctx=arg0.ctx, ptr=res) 546 def intersect(arg0, arg1): 547 try: 548 if not arg0.__class__ is map: 549 arg0 = map(arg0) 550 except: 551 raise 552 try: 553 if not arg1.__class__ is map: 554 arg1 = map(arg1) 555 except: 556 return union_map(arg0).intersect(arg1) 557 res = isl.isl_map_intersect(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 558 return map(ctx=arg0.ctx, ptr=res) 559 def intersect_params(arg0, arg1): 560 try: 561 if not arg0.__class__ is map: 562 arg0 = map(arg0) 563 except: 564 raise 565 try: 566 if not arg1.__class__ is set: 567 arg1 = set(arg1) 568 except: 569 return union_map(arg0).intersect_params(arg1) 570 res = isl.isl_map_intersect_params(isl.isl_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 571 return map(ctx=arg0.ctx, ptr=res) 572 def subtract(arg0, arg1): 573 try: 574 if not arg0.__class__ is map: 575 arg0 = map(arg0) 576 except: 577 raise 578 try: 579 if not arg1.__class__ is map: 580 arg1 = map(arg1) 581 except: 582 return union_map(arg0).subtract(arg1) 583 res = isl.isl_map_subtract(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 584 return map(ctx=arg0.ctx, ptr=res) 585 def complement(arg0): 586 try: 587 if not arg0.__class__ is map: 588 arg0 = map(arg0) 589 except: 590 raise 591 res = isl.isl_map_complement(isl.isl_map_copy(arg0.ptr)) 592 return map(ctx=arg0.ctx, ptr=res) 593 def deltas(arg0): 594 try: 595 if not arg0.__class__ is map: 596 arg0 = map(arg0) 597 except: 598 raise 599 res = isl.isl_map_deltas(isl.isl_map_copy(arg0.ptr)) 600 return set(ctx=arg0.ctx, ptr=res) 601 def detect_equalities(arg0): 602 try: 603 if not arg0.__class__ is map: 604 arg0 = map(arg0) 605 except: 606 raise 607 res = isl.isl_map_detect_equalities(isl.isl_map_copy(arg0.ptr)) 608 return map(ctx=arg0.ctx, ptr=res) 609 def affine_hull(arg0): 610 try: 611 if not arg0.__class__ is map: 612 arg0 = map(arg0) 613 except: 614 raise 615 res = isl.isl_map_affine_hull(isl.isl_map_copy(arg0.ptr)) 616 return basic_map(ctx=arg0.ctx, ptr=res) 617 def polyhedral_hull(arg0): 618 try: 619 if not arg0.__class__ is map: 620 arg0 = map(arg0) 621 except: 622 raise 623 res = isl.isl_map_polyhedral_hull(isl.isl_map_copy(arg0.ptr)) 624 return basic_map(ctx=arg0.ctx, ptr=res) 625 def flatten(arg0): 626 try: 627 if not arg0.__class__ is map: 628 arg0 = map(arg0) 629 except: 630 raise 631 res = isl.isl_map_flatten(isl.isl_map_copy(arg0.ptr)) 632 return map(ctx=arg0.ctx, ptr=res) 633 def flatten_domain(arg0): 634 try: 635 if not arg0.__class__ is map: 636 arg0 = map(arg0) 637 except: 638 raise 639 res = isl.isl_map_flatten_domain(isl.isl_map_copy(arg0.ptr)) 640 return map(ctx=arg0.ctx, ptr=res) 641 def flatten_range(arg0): 642 try: 643 if not arg0.__class__ is map: 644 arg0 = map(arg0) 645 except: 646 raise 647 res = isl.isl_map_flatten_range(isl.isl_map_copy(arg0.ptr)) 648 return map(ctx=arg0.ctx, ptr=res) 649 def sample(arg0): 650 try: 651 if not arg0.__class__ is map: 652 arg0 = map(arg0) 653 except: 654 raise 655 res = isl.isl_map_sample(isl.isl_map_copy(arg0.ptr)) 656 return basic_map(ctx=arg0.ctx, ptr=res) 657 def is_empty(arg0): 658 try: 659 if not arg0.__class__ is map: 660 arg0 = map(arg0) 661 except: 662 raise 663 res = isl.isl_map_is_empty(arg0.ptr) 664 return res 665 def is_subset(arg0, arg1): 666 try: 667 if not arg0.__class__ is map: 668 arg0 = map(arg0) 669 except: 670 raise 671 try: 672 if not arg1.__class__ is map: 673 arg1 = map(arg1) 674 except: 675 return union_map(arg0).is_subset(arg1) 676 res = isl.isl_map_is_subset(arg0.ptr, arg1.ptr) 677 return res 678 def is_strict_subset(arg0, arg1): 679 try: 680 if not arg0.__class__ is map: 681 arg0 = map(arg0) 682 except: 683 raise 684 try: 685 if not arg1.__class__ is map: 686 arg1 = map(arg1) 687 except: 688 return union_map(arg0).is_strict_subset(arg1) 689 res = isl.isl_map_is_strict_subset(arg0.ptr, arg1.ptr) 690 return res 691 def is_equal(arg0, arg1): 692 try: 693 if not arg0.__class__ is map: 694 arg0 = map(arg0) 695 except: 696 raise 697 try: 698 if not arg1.__class__ is map: 699 arg1 = map(arg1) 700 except: 701 return union_map(arg0).is_equal(arg1) 702 res = isl.isl_map_is_equal(arg0.ptr, arg1.ptr) 703 return res 704 def is_disjoint(arg0, arg1): 705 try: 706 if not arg0.__class__ is map: 707 arg0 = map(arg0) 708 except: 709 raise 710 try: 711 if not arg1.__class__ is map: 712 arg1 = map(arg1) 713 except: 714 return union_map(arg0).is_disjoint(arg1) 715 res = isl.isl_map_is_disjoint(arg0.ptr, arg1.ptr) 716 return res 717 def is_single_valued(arg0): 718 try: 719 if not arg0.__class__ is map: 720 arg0 = map(arg0) 721 except: 722 raise 723 res = isl.isl_map_is_single_valued(arg0.ptr) 724 return res 725 def is_injective(arg0): 726 try: 727 if not arg0.__class__ is map: 728 arg0 = map(arg0) 729 except: 730 raise 731 res = isl.isl_map_is_injective(arg0.ptr) 732 return res 733 def is_bijective(arg0): 734 try: 735 if not arg0.__class__ is map: 736 arg0 = map(arg0) 737 except: 738 raise 739 res = isl.isl_map_is_bijective(arg0.ptr) 740 return res 741 def gist(arg0, arg1): 742 try: 743 if not arg0.__class__ is map: 744 arg0 = map(arg0) 745 except: 746 raise 747 try: 748 if not arg1.__class__ is map: 749 arg1 = map(arg1) 750 except: 751 return union_map(arg0).gist(arg1) 752 res = isl.isl_map_gist(isl.isl_map_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 753 return map(ctx=arg0.ctx, ptr=res) 754 def gist_domain(arg0, arg1): 755 try: 756 if not arg0.__class__ is map: 757 arg0 = map(arg0) 758 except: 759 raise 760 try: 761 if not arg1.__class__ is set: 762 arg1 = set(arg1) 763 except: 764 return union_map(arg0).gist_domain(arg1) 765 res = isl.isl_map_gist_domain(isl.isl_map_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 766 return map(ctx=arg0.ctx, ptr=res) 767 def coalesce(arg0): 768 try: 769 if not arg0.__class__ is map: 770 arg0 = map(arg0) 771 except: 772 raise 773 res = isl.isl_map_coalesce(isl.isl_map_copy(arg0.ptr)) 774 return map(ctx=arg0.ctx, ptr=res) 775 def foreach_basic_map(arg0, arg1): 776 try: 777 if not arg0.__class__ is map: 778 arg0 = map(arg0) 779 except: 780 raise 781 exc_info = [None] 782 fn = CFUNCTYPE(c_int, c_void_p, c_void_p) 783 def cb_func(cb_arg0, cb_arg1): 784 cb_arg0 = basic_map(ctx=arg0.ctx, ptr=cb_arg0) 785 try: 786 arg1(cb_arg0) 787 except: 788 import sys 789 exc_info[0] = sys.exc_info() 790 return -1 791 return 0 792 cb = fn(cb_func) 793 res = isl.isl_map_foreach_basic_map(arg0.ptr, cb, None) 794 if exc_info[0] != None: 795 raise exc_info[0][0], exc_info[0][1], exc_info[0][2] 796 return res 797 798isl.isl_map_read_from_str.restype = c_void_p 799isl.isl_map_read_from_str.argtypes = [Context, c_char_p] 800isl.isl_map_from_basic_map.restype = c_void_p 801isl.isl_map_from_basic_map.argtypes = [c_void_p] 802isl.isl_map_lexmin.restype = c_void_p 803isl.isl_map_lexmax.restype = c_void_p 804isl.isl_map_reverse.restype = c_void_p 805isl.isl_map_union.restype = c_void_p 806isl.isl_map_intersect_domain.restype = c_void_p 807isl.isl_map_intersect_range.restype = c_void_p 808isl.isl_map_apply_domain.restype = c_void_p 809isl.isl_map_apply_range.restype = c_void_p 810isl.isl_map_intersect.restype = c_void_p 811isl.isl_map_intersect_params.restype = c_void_p 812isl.isl_map_subtract.restype = c_void_p 813isl.isl_map_complement.restype = c_void_p 814isl.isl_map_deltas.restype = c_void_p 815isl.isl_map_detect_equalities.restype = c_void_p 816isl.isl_map_affine_hull.restype = c_void_p 817isl.isl_map_polyhedral_hull.restype = c_void_p 818isl.isl_map_flatten.restype = c_void_p 819isl.isl_map_flatten_domain.restype = c_void_p 820isl.isl_map_flatten_range.restype = c_void_p 821isl.isl_map_sample.restype = c_void_p 822isl.isl_map_gist.restype = c_void_p 823isl.isl_map_gist_domain.restype = c_void_p 824isl.isl_map_coalesce.restype = c_void_p 825isl.isl_map_free.argtypes = [c_void_p] 826isl.isl_map_to_str.argtypes = [c_void_p] 827isl.isl_map_to_str.restype = POINTER(c_char) 828 829class basic_map(map): 830 def __init__(self, *args, **keywords): 831 if "ptr" in keywords: 832 self.ctx = keywords["ctx"] 833 self.ptr = keywords["ptr"] 834 return 835 if len(args) == 1 and type(args[0]) == str: 836 self.ctx = Context.getDefaultInstance() 837 self.ptr = isl.isl_basic_map_read_from_str(self.ctx, args[0]) 838 return 839 raise Error 840 def __del__(self): 841 if hasattr(self, 'ptr'): 842 isl.isl_basic_map_free(self.ptr) 843 def __str__(self): 844 ptr = isl.isl_basic_map_to_str(self.ptr) 845 res = str(cast(ptr, c_char_p).value) 846 libc.free(ptr) 847 return res 848 def __repr__(self): 849 return 'isl.basic_map("%s")' % str(self) 850 def intersect_domain(arg0, arg1): 851 try: 852 if not arg0.__class__ is basic_map: 853 arg0 = basic_map(arg0) 854 except: 855 raise 856 try: 857 if not arg1.__class__ is basic_set: 858 arg1 = basic_set(arg1) 859 except: 860 return map(arg0).intersect_domain(arg1) 861 res = isl.isl_basic_map_intersect_domain(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 862 return basic_map(ctx=arg0.ctx, ptr=res) 863 def intersect_range(arg0, arg1): 864 try: 865 if not arg0.__class__ is basic_map: 866 arg0 = basic_map(arg0) 867 except: 868 raise 869 try: 870 if not arg1.__class__ is basic_set: 871 arg1 = basic_set(arg1) 872 except: 873 return map(arg0).intersect_range(arg1) 874 res = isl.isl_basic_map_intersect_range(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 875 return basic_map(ctx=arg0.ctx, ptr=res) 876 def intersect(arg0, arg1): 877 try: 878 if not arg0.__class__ is basic_map: 879 arg0 = basic_map(arg0) 880 except: 881 raise 882 try: 883 if not arg1.__class__ is basic_map: 884 arg1 = basic_map(arg1) 885 except: 886 return map(arg0).intersect(arg1) 887 res = isl.isl_basic_map_intersect(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 888 return basic_map(ctx=arg0.ctx, ptr=res) 889 def union(arg0, arg1): 890 try: 891 if not arg0.__class__ is basic_map: 892 arg0 = basic_map(arg0) 893 except: 894 raise 895 try: 896 if not arg1.__class__ is basic_map: 897 arg1 = basic_map(arg1) 898 except: 899 return map(arg0).union(arg1) 900 res = isl.isl_basic_map_union(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 901 return map(ctx=arg0.ctx, ptr=res) 902 def apply_domain(arg0, arg1): 903 try: 904 if not arg0.__class__ is basic_map: 905 arg0 = basic_map(arg0) 906 except: 907 raise 908 try: 909 if not arg1.__class__ is basic_map: 910 arg1 = basic_map(arg1) 911 except: 912 return map(arg0).apply_domain(arg1) 913 res = isl.isl_basic_map_apply_domain(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 914 return basic_map(ctx=arg0.ctx, ptr=res) 915 def apply_range(arg0, arg1): 916 try: 917 if not arg0.__class__ is basic_map: 918 arg0 = basic_map(arg0) 919 except: 920 raise 921 try: 922 if not arg1.__class__ is basic_map: 923 arg1 = basic_map(arg1) 924 except: 925 return map(arg0).apply_range(arg1) 926 res = isl.isl_basic_map_apply_range(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 927 return basic_map(ctx=arg0.ctx, ptr=res) 928 def affine_hull(arg0): 929 try: 930 if not arg0.__class__ is basic_map: 931 arg0 = basic_map(arg0) 932 except: 933 raise 934 res = isl.isl_basic_map_affine_hull(isl.isl_basic_map_copy(arg0.ptr)) 935 return basic_map(ctx=arg0.ctx, ptr=res) 936 def reverse(arg0): 937 try: 938 if not arg0.__class__ is basic_map: 939 arg0 = basic_map(arg0) 940 except: 941 raise 942 res = isl.isl_basic_map_reverse(isl.isl_basic_map_copy(arg0.ptr)) 943 return basic_map(ctx=arg0.ctx, ptr=res) 944 def sample(arg0): 945 try: 946 if not arg0.__class__ is basic_map: 947 arg0 = basic_map(arg0) 948 except: 949 raise 950 res = isl.isl_basic_map_sample(isl.isl_basic_map_copy(arg0.ptr)) 951 return basic_map(ctx=arg0.ctx, ptr=res) 952 def detect_equalities(arg0): 953 try: 954 if not arg0.__class__ is basic_map: 955 arg0 = basic_map(arg0) 956 except: 957 raise 958 res = isl.isl_basic_map_detect_equalities(isl.isl_basic_map_copy(arg0.ptr)) 959 return basic_map(ctx=arg0.ctx, ptr=res) 960 def is_equal(arg0, arg1): 961 try: 962 if not arg0.__class__ is basic_map: 963 arg0 = basic_map(arg0) 964 except: 965 raise 966 try: 967 if not arg1.__class__ is basic_map: 968 arg1 = basic_map(arg1) 969 except: 970 return map(arg0).is_equal(arg1) 971 res = isl.isl_basic_map_is_equal(arg0.ptr, arg1.ptr) 972 return res 973 def lexmin(arg0): 974 try: 975 if not arg0.__class__ is basic_map: 976 arg0 = basic_map(arg0) 977 except: 978 raise 979 res = isl.isl_basic_map_lexmin(isl.isl_basic_map_copy(arg0.ptr)) 980 return map(ctx=arg0.ctx, ptr=res) 981 def lexmax(arg0): 982 try: 983 if not arg0.__class__ is basic_map: 984 arg0 = basic_map(arg0) 985 except: 986 raise 987 res = isl.isl_basic_map_lexmax(isl.isl_basic_map_copy(arg0.ptr)) 988 return map(ctx=arg0.ctx, ptr=res) 989 def is_empty(arg0): 990 try: 991 if not arg0.__class__ is basic_map: 992 arg0 = basic_map(arg0) 993 except: 994 raise 995 res = isl.isl_basic_map_is_empty(arg0.ptr) 996 return res 997 def is_subset(arg0, arg1): 998 try: 999 if not arg0.__class__ is basic_map: 1000 arg0 = basic_map(arg0) 1001 except: 1002 raise 1003 try: 1004 if not arg1.__class__ is basic_map: 1005 arg1 = basic_map(arg1) 1006 except: 1007 return map(arg0).is_subset(arg1) 1008 res = isl.isl_basic_map_is_subset(arg0.ptr, arg1.ptr) 1009 return res 1010 def deltas(arg0): 1011 try: 1012 if not arg0.__class__ is basic_map: 1013 arg0 = basic_map(arg0) 1014 except: 1015 raise 1016 res = isl.isl_basic_map_deltas(isl.isl_basic_map_copy(arg0.ptr)) 1017 return basic_set(ctx=arg0.ctx, ptr=res) 1018 def flatten(arg0): 1019 try: 1020 if not arg0.__class__ is basic_map: 1021 arg0 = basic_map(arg0) 1022 except: 1023 raise 1024 res = isl.isl_basic_map_flatten(isl.isl_basic_map_copy(arg0.ptr)) 1025 return basic_map(ctx=arg0.ctx, ptr=res) 1026 def flatten_domain(arg0): 1027 try: 1028 if not arg0.__class__ is basic_map: 1029 arg0 = basic_map(arg0) 1030 except: 1031 raise 1032 res = isl.isl_basic_map_flatten_domain(isl.isl_basic_map_copy(arg0.ptr)) 1033 return basic_map(ctx=arg0.ctx, ptr=res) 1034 def flatten_range(arg0): 1035 try: 1036 if not arg0.__class__ is basic_map: 1037 arg0 = basic_map(arg0) 1038 except: 1039 raise 1040 res = isl.isl_basic_map_flatten_range(isl.isl_basic_map_copy(arg0.ptr)) 1041 return basic_map(ctx=arg0.ctx, ptr=res) 1042 def gist(arg0, arg1): 1043 try: 1044 if not arg0.__class__ is basic_map: 1045 arg0 = basic_map(arg0) 1046 except: 1047 raise 1048 try: 1049 if not arg1.__class__ is basic_map: 1050 arg1 = basic_map(arg1) 1051 except: 1052 return map(arg0).gist(arg1) 1053 res = isl.isl_basic_map_gist(isl.isl_basic_map_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 1054 return basic_map(ctx=arg0.ctx, ptr=res) 1055 1056isl.isl_basic_map_read_from_str.restype = c_void_p 1057isl.isl_basic_map_read_from_str.argtypes = [Context, c_char_p] 1058isl.isl_basic_map_intersect_domain.restype = c_void_p 1059isl.isl_basic_map_intersect_range.restype = c_void_p 1060isl.isl_basic_map_intersect.restype = c_void_p 1061isl.isl_basic_map_union.restype = c_void_p 1062isl.isl_basic_map_apply_domain.restype = c_void_p 1063isl.isl_basic_map_apply_range.restype = c_void_p 1064isl.isl_basic_map_affine_hull.restype = c_void_p 1065isl.isl_basic_map_reverse.restype = c_void_p 1066isl.isl_basic_map_sample.restype = c_void_p 1067isl.isl_basic_map_detect_equalities.restype = c_void_p 1068isl.isl_basic_map_lexmin.restype = c_void_p 1069isl.isl_basic_map_lexmax.restype = c_void_p 1070isl.isl_basic_map_deltas.restype = c_void_p 1071isl.isl_basic_map_flatten.restype = c_void_p 1072isl.isl_basic_map_flatten_domain.restype = c_void_p 1073isl.isl_basic_map_flatten_range.restype = c_void_p 1074isl.isl_basic_map_gist.restype = c_void_p 1075isl.isl_basic_map_free.argtypes = [c_void_p] 1076isl.isl_basic_map_to_str.argtypes = [c_void_p] 1077isl.isl_basic_map_to_str.restype = POINTER(c_char) 1078 1079class union_set: 1080 def __init__(self, *args, **keywords): 1081 if "ptr" in keywords: 1082 self.ctx = keywords["ctx"] 1083 self.ptr = keywords["ptr"] 1084 return 1085 if len(args) == 1 and type(args[0]) == str: 1086 self.ctx = Context.getDefaultInstance() 1087 self.ptr = isl.isl_union_set_read_from_str(self.ctx, args[0]) 1088 return 1089 if len(args) == 1 and args[0].__class__ is basic_set: 1090 self.ctx = Context.getDefaultInstance() 1091 self.ptr = isl.isl_union_set_from_basic_set(isl.isl_basic_set_copy(args[0].ptr)) 1092 return 1093 if len(args) == 1 and args[0].__class__ is set: 1094 self.ctx = Context.getDefaultInstance() 1095 self.ptr = isl.isl_union_set_from_set(isl.isl_set_copy(args[0].ptr)) 1096 return 1097 raise Error 1098 def __del__(self): 1099 if hasattr(self, 'ptr'): 1100 isl.isl_union_set_free(self.ptr) 1101 def __str__(self): 1102 ptr = isl.isl_union_set_to_str(self.ptr) 1103 res = str(cast(ptr, c_char_p).value) 1104 libc.free(ptr) 1105 return res 1106 def __repr__(self): 1107 return 'isl.union_set("%s")' % str(self) 1108 def identity(arg0): 1109 try: 1110 if not arg0.__class__ is union_set: 1111 arg0 = union_set(arg0) 1112 except: 1113 raise 1114 res = isl.isl_union_set_identity(isl.isl_union_set_copy(arg0.ptr)) 1115 return union_map(ctx=arg0.ctx, ptr=res) 1116 def detect_equalities(arg0): 1117 try: 1118 if not arg0.__class__ is union_set: 1119 arg0 = union_set(arg0) 1120 except: 1121 raise 1122 res = isl.isl_union_set_detect_equalities(isl.isl_union_set_copy(arg0.ptr)) 1123 return union_set(ctx=arg0.ctx, ptr=res) 1124 def affine_hull(arg0): 1125 try: 1126 if not arg0.__class__ is union_set: 1127 arg0 = union_set(arg0) 1128 except: 1129 raise 1130 res = isl.isl_union_set_affine_hull(isl.isl_union_set_copy(arg0.ptr)) 1131 return union_set(ctx=arg0.ctx, ptr=res) 1132 def polyhedral_hull(arg0): 1133 try: 1134 if not arg0.__class__ is union_set: 1135 arg0 = union_set(arg0) 1136 except: 1137 raise 1138 res = isl.isl_union_set_polyhedral_hull(isl.isl_union_set_copy(arg0.ptr)) 1139 return union_set(ctx=arg0.ctx, ptr=res) 1140 def coalesce(arg0): 1141 try: 1142 if not arg0.__class__ is union_set: 1143 arg0 = union_set(arg0) 1144 except: 1145 raise 1146 res = isl.isl_union_set_coalesce(isl.isl_union_set_copy(arg0.ptr)) 1147 return union_set(ctx=arg0.ctx, ptr=res) 1148 def lexmin(arg0): 1149 try: 1150 if not arg0.__class__ is union_set: 1151 arg0 = union_set(arg0) 1152 except: 1153 raise 1154 res = isl.isl_union_set_lexmin(isl.isl_union_set_copy(arg0.ptr)) 1155 return union_set(ctx=arg0.ctx, ptr=res) 1156 def lexmax(arg0): 1157 try: 1158 if not arg0.__class__ is union_set: 1159 arg0 = union_set(arg0) 1160 except: 1161 raise 1162 res = isl.isl_union_set_lexmax(isl.isl_union_set_copy(arg0.ptr)) 1163 return union_set(ctx=arg0.ctx, ptr=res) 1164 def subtract(arg0, arg1): 1165 try: 1166 if not arg0.__class__ is union_set: 1167 arg0 = union_set(arg0) 1168 except: 1169 raise 1170 try: 1171 if not arg1.__class__ is union_set: 1172 arg1 = union_set(arg1) 1173 except: 1174 raise 1175 res = isl.isl_union_set_subtract(isl.isl_union_set_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 1176 return union_set(ctx=arg0.ctx, ptr=res) 1177 def intersect(arg0, arg1): 1178 try: 1179 if not arg0.__class__ is union_set: 1180 arg0 = union_set(arg0) 1181 except: 1182 raise 1183 try: 1184 if not arg1.__class__ is union_set: 1185 arg1 = union_set(arg1) 1186 except: 1187 raise 1188 res = isl.isl_union_set_intersect(isl.isl_union_set_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 1189 return union_set(ctx=arg0.ctx, ptr=res) 1190 def intersect_params(arg0, arg1): 1191 try: 1192 if not arg0.__class__ is union_set: 1193 arg0 = union_set(arg0) 1194 except: 1195 raise 1196 try: 1197 if not arg1.__class__ is set: 1198 arg1 = set(arg1) 1199 except: 1200 raise 1201 res = isl.isl_union_set_intersect_params(isl.isl_union_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1202 return union_set(ctx=arg0.ctx, ptr=res) 1203 def gist(arg0, arg1): 1204 try: 1205 if not arg0.__class__ is union_set: 1206 arg0 = union_set(arg0) 1207 except: 1208 raise 1209 try: 1210 if not arg1.__class__ is union_set: 1211 arg1 = union_set(arg1) 1212 except: 1213 raise 1214 res = isl.isl_union_set_gist(isl.isl_union_set_copy(arg0.ptr), isl.isl_union_set_copy(arg1.ptr)) 1215 return union_set(ctx=arg0.ctx, ptr=res) 1216 def gist_params(arg0, arg1): 1217 try: 1218 if not arg0.__class__ is union_set: 1219 arg0 = union_set(arg0) 1220 except: 1221 raise 1222 try: 1223 if not arg1.__class__ is set: 1224 arg1 = set(arg1) 1225 except: 1226 raise 1227 res = isl.isl_union_set_gist_params(isl.isl_union_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1228 return union_set(ctx=arg0.ctx, ptr=res) 1229 def apply(arg0, arg1): 1230 try: 1231 if not arg0.__class__ is union_set: 1232 arg0 = union_set(arg0) 1233 except: 1234 raise 1235 try: 1236 if not arg1.__class__ is union_map: 1237 arg1 = union_map(arg1) 1238 except: 1239 raise 1240 res = isl.isl_union_set_apply(isl.isl_union_set_copy(arg0.ptr), isl.isl_union_map_copy(arg1.ptr)) 1241 return union_set(ctx=arg0.ctx, ptr=res) 1242 def is_empty(arg0): 1243 try: 1244 if not arg0.__class__ is union_set: 1245 arg0 = union_set(arg0) 1246 except: 1247 raise 1248 res = isl.isl_union_set_is_empty(arg0.ptr) 1249 return res 1250 def is_subset(arg0, arg1): 1251 try: 1252 if not arg0.__class__ is union_set: 1253 arg0 = union_set(arg0) 1254 except: 1255 raise 1256 try: 1257 if not arg1.__class__ is union_set: 1258 arg1 = union_set(arg1) 1259 except: 1260 raise 1261 res = isl.isl_union_set_is_subset(arg0.ptr, arg1.ptr) 1262 return res 1263 def is_equal(arg0, arg1): 1264 try: 1265 if not arg0.__class__ is union_set: 1266 arg0 = union_set(arg0) 1267 except: 1268 raise 1269 try: 1270 if not arg1.__class__ is union_set: 1271 arg1 = union_set(arg1) 1272 except: 1273 raise 1274 res = isl.isl_union_set_is_equal(arg0.ptr, arg1.ptr) 1275 return res 1276 def is_strict_subset(arg0, arg1): 1277 try: 1278 if not arg0.__class__ is union_set: 1279 arg0 = union_set(arg0) 1280 except: 1281 raise 1282 try: 1283 if not arg1.__class__ is union_set: 1284 arg1 = union_set(arg1) 1285 except: 1286 raise 1287 res = isl.isl_union_set_is_strict_subset(arg0.ptr, arg1.ptr) 1288 return res 1289 def foreach_set(arg0, arg1): 1290 try: 1291 if not arg0.__class__ is union_set: 1292 arg0 = union_set(arg0) 1293 except: 1294 raise 1295 exc_info = [None] 1296 fn = CFUNCTYPE(c_int, c_void_p, c_void_p) 1297 def cb_func(cb_arg0, cb_arg1): 1298 cb_arg0 = set(ctx=arg0.ctx, ptr=cb_arg0) 1299 try: 1300 arg1(cb_arg0) 1301 except: 1302 import sys 1303 exc_info[0] = sys.exc_info() 1304 return -1 1305 return 0 1306 cb = fn(cb_func) 1307 res = isl.isl_union_set_foreach_set(arg0.ptr, cb, None) 1308 if exc_info[0] != None: 1309 raise exc_info[0][0], exc_info[0][1], exc_info[0][2] 1310 return res 1311 1312isl.isl_union_set_read_from_str.restype = c_void_p 1313isl.isl_union_set_read_from_str.argtypes = [Context, c_char_p] 1314isl.isl_union_set_from_basic_set.restype = c_void_p 1315isl.isl_union_set_from_basic_set.argtypes = [c_void_p] 1316isl.isl_union_set_from_set.restype = c_void_p 1317isl.isl_union_set_from_set.argtypes = [c_void_p] 1318isl.isl_union_set_identity.restype = c_void_p 1319isl.isl_union_set_detect_equalities.restype = c_void_p 1320isl.isl_union_set_affine_hull.restype = c_void_p 1321isl.isl_union_set_polyhedral_hull.restype = c_void_p 1322isl.isl_union_set_coalesce.restype = c_void_p 1323isl.isl_union_set_lexmin.restype = c_void_p 1324isl.isl_union_set_lexmax.restype = c_void_p 1325isl.isl_union_set_subtract.restype = c_void_p 1326isl.isl_union_set_intersect.restype = c_void_p 1327isl.isl_union_set_intersect_params.restype = c_void_p 1328isl.isl_union_set_gist.restype = c_void_p 1329isl.isl_union_set_gist_params.restype = c_void_p 1330isl.isl_union_set_apply.restype = c_void_p 1331isl.isl_union_set_free.argtypes = [c_void_p] 1332isl.isl_union_set_to_str.argtypes = [c_void_p] 1333isl.isl_union_set_to_str.restype = POINTER(c_char) 1334 1335class set(union_set): 1336 def __init__(self, *args, **keywords): 1337 if "ptr" in keywords: 1338 self.ctx = keywords["ctx"] 1339 self.ptr = keywords["ptr"] 1340 return 1341 if len(args) == 1 and type(args[0]) == str: 1342 self.ctx = Context.getDefaultInstance() 1343 self.ptr = isl.isl_set_read_from_str(self.ctx, args[0]) 1344 return 1345 if len(args) == 1 and args[0].__class__ is basic_set: 1346 self.ctx = Context.getDefaultInstance() 1347 self.ptr = isl.isl_set_from_basic_set(isl.isl_basic_set_copy(args[0].ptr)) 1348 return 1349 raise Error 1350 def __del__(self): 1351 if hasattr(self, 'ptr'): 1352 isl.isl_set_free(self.ptr) 1353 def __str__(self): 1354 ptr = isl.isl_set_to_str(self.ptr) 1355 res = str(cast(ptr, c_char_p).value) 1356 libc.free(ptr) 1357 return res 1358 def __repr__(self): 1359 return 'isl.set("%s")' % str(self) 1360 def lexmin(arg0): 1361 try: 1362 if not arg0.__class__ is set: 1363 arg0 = set(arg0) 1364 except: 1365 raise 1366 res = isl.isl_set_lexmin(isl.isl_set_copy(arg0.ptr)) 1367 return set(ctx=arg0.ctx, ptr=res) 1368 def lexmax(arg0): 1369 try: 1370 if not arg0.__class__ is set: 1371 arg0 = set(arg0) 1372 except: 1373 raise 1374 res = isl.isl_set_lexmax(isl.isl_set_copy(arg0.ptr)) 1375 return set(ctx=arg0.ctx, ptr=res) 1376 def sample(arg0): 1377 try: 1378 if not arg0.__class__ is set: 1379 arg0 = set(arg0) 1380 except: 1381 raise 1382 res = isl.isl_set_sample(isl.isl_set_copy(arg0.ptr)) 1383 return basic_set(ctx=arg0.ctx, ptr=res) 1384 def detect_equalities(arg0): 1385 try: 1386 if not arg0.__class__ is set: 1387 arg0 = set(arg0) 1388 except: 1389 raise 1390 res = isl.isl_set_detect_equalities(isl.isl_set_copy(arg0.ptr)) 1391 return set(ctx=arg0.ctx, ptr=res) 1392 def affine_hull(arg0): 1393 try: 1394 if not arg0.__class__ is set: 1395 arg0 = set(arg0) 1396 except: 1397 raise 1398 res = isl.isl_set_affine_hull(isl.isl_set_copy(arg0.ptr)) 1399 return basic_set(ctx=arg0.ctx, ptr=res) 1400 def polyhedral_hull(arg0): 1401 try: 1402 if not arg0.__class__ is set: 1403 arg0 = set(arg0) 1404 except: 1405 raise 1406 res = isl.isl_set_polyhedral_hull(isl.isl_set_copy(arg0.ptr)) 1407 return basic_set(ctx=arg0.ctx, ptr=res) 1408 def union(arg0, arg1): 1409 try: 1410 if not arg0.__class__ is set: 1411 arg0 = set(arg0) 1412 except: 1413 raise 1414 try: 1415 if not arg1.__class__ is set: 1416 arg1 = set(arg1) 1417 except: 1418 return union_set(arg0).union(arg1) 1419 res = isl.isl_set_union(isl.isl_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1420 return set(ctx=arg0.ctx, ptr=res) 1421 def intersect(arg0, arg1): 1422 try: 1423 if not arg0.__class__ is set: 1424 arg0 = set(arg0) 1425 except: 1426 raise 1427 try: 1428 if not arg1.__class__ is set: 1429 arg1 = set(arg1) 1430 except: 1431 return union_set(arg0).intersect(arg1) 1432 res = isl.isl_set_intersect(isl.isl_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1433 return set(ctx=arg0.ctx, ptr=res) 1434 def intersect_params(arg0, arg1): 1435 try: 1436 if not arg0.__class__ is set: 1437 arg0 = set(arg0) 1438 except: 1439 raise 1440 try: 1441 if not arg1.__class__ is set: 1442 arg1 = set(arg1) 1443 except: 1444 return union_set(arg0).intersect_params(arg1) 1445 res = isl.isl_set_intersect_params(isl.isl_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1446 return set(ctx=arg0.ctx, ptr=res) 1447 def subtract(arg0, arg1): 1448 try: 1449 if not arg0.__class__ is set: 1450 arg0 = set(arg0) 1451 except: 1452 raise 1453 try: 1454 if not arg1.__class__ is set: 1455 arg1 = set(arg1) 1456 except: 1457 return union_set(arg0).subtract(arg1) 1458 res = isl.isl_set_subtract(isl.isl_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1459 return set(ctx=arg0.ctx, ptr=res) 1460 def complement(arg0): 1461 try: 1462 if not arg0.__class__ is set: 1463 arg0 = set(arg0) 1464 except: 1465 raise 1466 res = isl.isl_set_complement(isl.isl_set_copy(arg0.ptr)) 1467 return set(ctx=arg0.ctx, ptr=res) 1468 def apply(arg0, arg1): 1469 try: 1470 if not arg0.__class__ is set: 1471 arg0 = set(arg0) 1472 except: 1473 raise 1474 try: 1475 if not arg1.__class__ is map: 1476 arg1 = map(arg1) 1477 except: 1478 return union_set(arg0).apply(arg1) 1479 res = isl.isl_set_apply(isl.isl_set_copy(arg0.ptr), isl.isl_map_copy(arg1.ptr)) 1480 return set(ctx=arg0.ctx, ptr=res) 1481 def is_empty(arg0): 1482 try: 1483 if not arg0.__class__ is set: 1484 arg0 = set(arg0) 1485 except: 1486 raise 1487 res = isl.isl_set_is_empty(arg0.ptr) 1488 return res 1489 def is_subset(arg0, arg1): 1490 try: 1491 if not arg0.__class__ is set: 1492 arg0 = set(arg0) 1493 except: 1494 raise 1495 try: 1496 if not arg1.__class__ is set: 1497 arg1 = set(arg1) 1498 except: 1499 return union_set(arg0).is_subset(arg1) 1500 res = isl.isl_set_is_subset(arg0.ptr, arg1.ptr) 1501 return res 1502 def is_strict_subset(arg0, arg1): 1503 try: 1504 if not arg0.__class__ is set: 1505 arg0 = set(arg0) 1506 except: 1507 raise 1508 try: 1509 if not arg1.__class__ is set: 1510 arg1 = set(arg1) 1511 except: 1512 return union_set(arg0).is_strict_subset(arg1) 1513 res = isl.isl_set_is_strict_subset(arg0.ptr, arg1.ptr) 1514 return res 1515 def is_equal(arg0, arg1): 1516 try: 1517 if not arg0.__class__ is set: 1518 arg0 = set(arg0) 1519 except: 1520 raise 1521 try: 1522 if not arg1.__class__ is set: 1523 arg1 = set(arg1) 1524 except: 1525 return union_set(arg0).is_equal(arg1) 1526 res = isl.isl_set_is_equal(arg0.ptr, arg1.ptr) 1527 return res 1528 def is_disjoint(arg0, arg1): 1529 try: 1530 if not arg0.__class__ is set: 1531 arg0 = set(arg0) 1532 except: 1533 raise 1534 try: 1535 if not arg1.__class__ is set: 1536 arg1 = set(arg1) 1537 except: 1538 return union_set(arg0).is_disjoint(arg1) 1539 res = isl.isl_set_is_disjoint(arg0.ptr, arg1.ptr) 1540 return res 1541 def gist(arg0, arg1): 1542 try: 1543 if not arg0.__class__ is set: 1544 arg0 = set(arg0) 1545 except: 1546 raise 1547 try: 1548 if not arg1.__class__ is set: 1549 arg1 = set(arg1) 1550 except: 1551 return union_set(arg0).gist(arg1) 1552 res = isl.isl_set_gist(isl.isl_set_copy(arg0.ptr), isl.isl_set_copy(arg1.ptr)) 1553 return set(ctx=arg0.ctx, ptr=res) 1554 def coalesce(arg0): 1555 try: 1556 if not arg0.__class__ is set: 1557 arg0 = set(arg0) 1558 except: 1559 raise 1560 res = isl.isl_set_coalesce(isl.isl_set_copy(arg0.ptr)) 1561 return set(ctx=arg0.ctx, ptr=res) 1562 def foreach_basic_set(arg0, arg1): 1563 try: 1564 if not arg0.__class__ is set: 1565 arg0 = set(arg0) 1566 except: 1567 raise 1568 exc_info = [None] 1569 fn = CFUNCTYPE(c_int, c_void_p, c_void_p) 1570 def cb_func(cb_arg0, cb_arg1): 1571 cb_arg0 = basic_set(ctx=arg0.ctx, ptr=cb_arg0) 1572 try: 1573 arg1(cb_arg0) 1574 except: 1575 import sys 1576 exc_info[0] = sys.exc_info() 1577 return -1 1578 return 0 1579 cb = fn(cb_func) 1580 res = isl.isl_set_foreach_basic_set(arg0.ptr, cb, None) 1581 if exc_info[0] != None: 1582 raise exc_info[0][0], exc_info[0][1], exc_info[0][2] 1583 return res 1584 def identity(arg0): 1585 try: 1586 if not arg0.__class__ is set: 1587 arg0 = set(arg0) 1588 except: 1589 raise 1590 res = isl.isl_set_identity(isl.isl_set_copy(arg0.ptr)) 1591 return map(ctx=arg0.ctx, ptr=res) 1592 def is_wrapping(arg0): 1593 try: 1594 if not arg0.__class__ is set: 1595 arg0 = set(arg0) 1596 except: 1597 raise 1598 res = isl.isl_set_is_wrapping(arg0.ptr) 1599 return res 1600 def flatten(arg0): 1601 try: 1602 if not arg0.__class__ is set: 1603 arg0 = set(arg0) 1604 except: 1605 raise 1606 res = isl.isl_set_flatten(isl.isl_set_copy(arg0.ptr)) 1607 return set(ctx=arg0.ctx, ptr=res) 1608 1609isl.isl_set_read_from_str.restype = c_void_p 1610isl.isl_set_read_from_str.argtypes = [Context, c_char_p] 1611isl.isl_set_from_basic_set.restype = c_void_p 1612isl.isl_set_from_basic_set.argtypes = [c_void_p] 1613isl.isl_set_lexmin.restype = c_void_p 1614isl.isl_set_lexmax.restype = c_void_p 1615isl.isl_set_sample.restype = c_void_p 1616isl.isl_set_detect_equalities.restype = c_void_p 1617isl.isl_set_affine_hull.restype = c_void_p 1618isl.isl_set_polyhedral_hull.restype = c_void_p 1619isl.isl_set_union.restype = c_void_p 1620isl.isl_set_intersect.restype = c_void_p 1621isl.isl_set_intersect_params.restype = c_void_p 1622isl.isl_set_subtract.restype = c_void_p 1623isl.isl_set_complement.restype = c_void_p 1624isl.isl_set_apply.restype = c_void_p 1625isl.isl_set_gist.restype = c_void_p 1626isl.isl_set_coalesce.restype = c_void_p 1627isl.isl_set_identity.restype = c_void_p 1628isl.isl_set_flatten.restype = c_void_p 1629isl.isl_set_free.argtypes = [c_void_p] 1630isl.isl_set_to_str.argtypes = [c_void_p] 1631isl.isl_set_to_str.restype = POINTER(c_char) 1632 1633class basic_set(set): 1634 def __init__(self, *args, **keywords): 1635 if "ptr" in keywords: 1636 self.ctx = keywords["ctx"] 1637 self.ptr = keywords["ptr"] 1638 return 1639 if len(args) == 1 and type(args[0]) == str: 1640 self.ctx = Context.getDefaultInstance() 1641 self.ptr = isl.isl_basic_set_read_from_str(self.ctx, args[0]) 1642 return 1643 raise Error 1644 def __del__(self): 1645 if hasattr(self, 'ptr'): 1646 isl.isl_basic_set_free(self.ptr) 1647 def __str__(self): 1648 ptr = isl.isl_basic_set_to_str(self.ptr) 1649 res = str(cast(ptr, c_char_p).value) 1650 libc.free(ptr) 1651 return res 1652 def __repr__(self): 1653 return 'isl.basic_set("%s")' % str(self) 1654 def intersect(arg0, arg1): 1655 try: 1656 if not arg0.__class__ is basic_set: 1657 arg0 = basic_set(arg0) 1658 except: 1659 raise 1660 try: 1661 if not arg1.__class__ is basic_set: 1662 arg1 = basic_set(arg1) 1663 except: 1664 return set(arg0).intersect(arg1) 1665 res = isl.isl_basic_set_intersect(isl.isl_basic_set_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 1666 return basic_set(ctx=arg0.ctx, ptr=res) 1667 def intersect_params(arg0, arg1): 1668 try: 1669 if not arg0.__class__ is basic_set: 1670 arg0 = basic_set(arg0) 1671 except: 1672 raise 1673 try: 1674 if not arg1.__class__ is basic_set: 1675 arg1 = basic_set(arg1) 1676 except: 1677 return set(arg0).intersect_params(arg1) 1678 res = isl.isl_basic_set_intersect_params(isl.isl_basic_set_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 1679 return basic_set(ctx=arg0.ctx, ptr=res) 1680 def apply(arg0, arg1): 1681 try: 1682 if not arg0.__class__ is basic_set: 1683 arg0 = basic_set(arg0) 1684 except: 1685 raise 1686 try: 1687 if not arg1.__class__ is basic_map: 1688 arg1 = basic_map(arg1) 1689 except: 1690 return set(arg0).apply(arg1) 1691 res = isl.isl_basic_set_apply(isl.isl_basic_set_copy(arg0.ptr), isl.isl_basic_map_copy(arg1.ptr)) 1692 return basic_set(ctx=arg0.ctx, ptr=res) 1693 def affine_hull(arg0): 1694 try: 1695 if not arg0.__class__ is basic_set: 1696 arg0 = basic_set(arg0) 1697 except: 1698 raise 1699 res = isl.isl_basic_set_affine_hull(isl.isl_basic_set_copy(arg0.ptr)) 1700 return basic_set(ctx=arg0.ctx, ptr=res) 1701 def sample(arg0): 1702 try: 1703 if not arg0.__class__ is basic_set: 1704 arg0 = basic_set(arg0) 1705 except: 1706 raise 1707 res = isl.isl_basic_set_sample(isl.isl_basic_set_copy(arg0.ptr)) 1708 return basic_set(ctx=arg0.ctx, ptr=res) 1709 def detect_equalities(arg0): 1710 try: 1711 if not arg0.__class__ is basic_set: 1712 arg0 = basic_set(arg0) 1713 except: 1714 raise 1715 res = isl.isl_basic_set_detect_equalities(isl.isl_basic_set_copy(arg0.ptr)) 1716 return basic_set(ctx=arg0.ctx, ptr=res) 1717 def is_equal(arg0, arg1): 1718 res = isl.isl_basic_set_is_equal(arg0.ptr, arg1.ptr) 1719 return res 1720 def lexmin(arg0): 1721 try: 1722 if not arg0.__class__ is basic_set: 1723 arg0 = basic_set(arg0) 1724 except: 1725 raise 1726 res = isl.isl_basic_set_lexmin(isl.isl_basic_set_copy(arg0.ptr)) 1727 return set(ctx=arg0.ctx, ptr=res) 1728 def lexmax(arg0): 1729 try: 1730 if not arg0.__class__ is basic_set: 1731 arg0 = basic_set(arg0) 1732 except: 1733 raise 1734 res = isl.isl_basic_set_lexmax(isl.isl_basic_set_copy(arg0.ptr)) 1735 return set(ctx=arg0.ctx, ptr=res) 1736 def union(arg0, arg1): 1737 try: 1738 if not arg0.__class__ is basic_set: 1739 arg0 = basic_set(arg0) 1740 except: 1741 raise 1742 try: 1743 if not arg1.__class__ is basic_set: 1744 arg1 = basic_set(arg1) 1745 except: 1746 return set(arg0).union(arg1) 1747 res = isl.isl_basic_set_union(isl.isl_basic_set_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 1748 return set(ctx=arg0.ctx, ptr=res) 1749 def is_empty(arg0): 1750 try: 1751 if not arg0.__class__ is basic_set: 1752 arg0 = basic_set(arg0) 1753 except: 1754 raise 1755 res = isl.isl_basic_set_is_empty(arg0.ptr) 1756 return res 1757 def is_subset(arg0, arg1): 1758 try: 1759 if not arg0.__class__ is basic_set: 1760 arg0 = basic_set(arg0) 1761 except: 1762 raise 1763 try: 1764 if not arg1.__class__ is basic_set: 1765 arg1 = basic_set(arg1) 1766 except: 1767 return set(arg0).is_subset(arg1) 1768 res = isl.isl_basic_set_is_subset(arg0.ptr, arg1.ptr) 1769 return res 1770 def gist(arg0, arg1): 1771 try: 1772 if not arg0.__class__ is basic_set: 1773 arg0 = basic_set(arg0) 1774 except: 1775 raise 1776 try: 1777 if not arg1.__class__ is basic_set: 1778 arg1 = basic_set(arg1) 1779 except: 1780 return set(arg0).gist(arg1) 1781 res = isl.isl_basic_set_gist(isl.isl_basic_set_copy(arg0.ptr), isl.isl_basic_set_copy(arg1.ptr)) 1782 return basic_set(ctx=arg0.ctx, ptr=res) 1783 def is_wrapping(arg0): 1784 try: 1785 if not arg0.__class__ is basic_set: 1786 arg0 = basic_set(arg0) 1787 except: 1788 raise 1789 res = isl.isl_basic_set_is_wrapping(arg0.ptr) 1790 return res 1791 def flatten(arg0): 1792 try: 1793 if not arg0.__class__ is basic_set: 1794 arg0 = basic_set(arg0) 1795 except: 1796 raise 1797 res = isl.isl_basic_set_flatten(isl.isl_basic_set_copy(arg0.ptr)) 1798 return basic_set(ctx=arg0.ctx, ptr=res) 1799 1800isl.isl_basic_set_read_from_str.restype = c_void_p 1801isl.isl_basic_set_read_from_str.argtypes = [Context, c_char_p] 1802isl.isl_basic_set_intersect.restype = c_void_p 1803isl.isl_basic_set_intersect_params.restype = c_void_p 1804isl.isl_basic_set_apply.restype = c_void_p 1805isl.isl_basic_set_affine_hull.restype = c_void_p 1806isl.isl_basic_set_sample.restype = c_void_p 1807isl.isl_basic_set_detect_equalities.restype = c_void_p 1808isl.isl_basic_set_lexmin.restype = c_void_p 1809isl.isl_basic_set_lexmax.restype = c_void_p 1810isl.isl_basic_set_union.restype = c_void_p 1811isl.isl_basic_set_gist.restype = c_void_p 1812isl.isl_basic_set_flatten.restype = c_void_p 1813isl.isl_basic_set_free.argtypes = [c_void_p] 1814isl.isl_basic_set_to_str.argtypes = [c_void_p] 1815isl.isl_basic_set_to_str.restype = POINTER(c_char) 1816 1817class pw_qpolynomial: 1818 def __init__(self, *args, **keywords): 1819 if "ptr" in keywords: 1820 self.ctx = keywords["ctx"] 1821 self.ptr = keywords["ptr"] 1822 return 1823 raise Error 1824 def __del__(self): 1825 if hasattr(self, 'ptr'): 1826 isl.isl_pw_qpolynomial_free(self.ptr) 1827 def __str__(self): 1828 ptr = isl.isl_pw_qpolynomial_to_str(self.ptr) 1829 res = str(cast(ptr, c_char_p).value) 1830 libc.free(ptr) 1831 return res 1832 def __repr__(self): 1833 return 'isl.pw_qpolynomial("%s")' % str(self) 1834 1835isl.isl_pw_qpolynomial_free.argtypes = [c_void_p] 1836isl.isl_pw_qpolynomial_to_str.argtypes = [c_void_p] 1837isl.isl_pw_qpolynomial_to_str.restype = POINTER(c_char) 1838 1839class union_pw_qpolynomial: 1840 def __init__(self, *args, **keywords): 1841 if "ptr" in keywords: 1842 self.ctx = keywords["ctx"] 1843 self.ptr = keywords["ptr"] 1844 return 1845 raise Error 1846 def __del__(self): 1847 if hasattr(self, 'ptr'): 1848 isl.isl_union_pw_qpolynomial_free(self.ptr) 1849 def __str__(self): 1850 ptr = isl.isl_union_pw_qpolynomial_to_str(self.ptr) 1851 res = str(cast(ptr, c_char_p).value) 1852 libc.free(ptr) 1853 return res 1854 def __repr__(self): 1855 return 'isl.union_pw_qpolynomial("%s")' % str(self) 1856 1857isl.isl_union_pw_qpolynomial_free.argtypes = [c_void_p] 1858isl.isl_union_pw_qpolynomial_to_str.argtypes = [c_void_p] 1859isl.isl_union_pw_qpolynomial_to_str.restype = POINTER(c_char) 1860