1 package org.python.core; 3 4 7 8 public class PyComplex extends PyObject { 9 public double real, imag; 10 11 static PyComplex J = new PyComplex(0, 1.); 12 13 14 15 public static final String exposed_name="complex"; 16 17 public static void typeSetup(PyObject dict,PyType.Newstyle marker) { 18 dict.__setitem__("imag",new PyGetSetDescr("imag",PyComplex.class,"getImag",null)); 19 dict.__setitem__("real",new PyGetSetDescr("real",PyComplex.class,"getReal",null)); 20 class exposed___abs__ extends PyBuiltinFunctionNarrow { 21 22 private PyComplex self; 23 24 public PyObject getSelf() { 25 return self; 26 } 27 28 exposed___abs__(PyComplex self,PyBuiltinFunction.Info info) { 29 super(info); 30 this.self=self; 31 } 32 33 public PyBuiltinFunction makeBound(PyObject self) { 34 return new exposed___abs__((PyComplex)self,info); 35 } 36 37 public PyObject __call__() { 38 return self.complex___abs__(); 39 } 40 41 public PyObject inst_call(PyObject gself) { 42 PyComplex self=(PyComplex)gself; 43 return self.complex___abs__(); 44 } 45 46 } 47 dict.__setitem__("__abs__",new PyMethodDescr("__abs__",PyComplex.class,0,0,new exposed___abs__(null,null))); 48 class exposed___float__ extends PyBuiltinFunctionNarrow { 49 50 private PyComplex self; 51 52 public PyObject getSelf() { 53 return self; 54 } 55 56 exposed___float__(PyComplex self,PyBuiltinFunction.Info info) { 57 super(info); 58 this.self=self; 59 } 60 61 public PyBuiltinFunction makeBound(PyObject self) { 62 return new exposed___float__((PyComplex)self,info); 63 } 64 65 public PyObject __call__() { 66 return self.complex___float__(); 67 } 68 69 public PyObject inst_call(PyObject gself) { 70 PyComplex self=(PyComplex)gself; 71 return self.complex___float__(); 72 } 73 74 } 75 dict.__setitem__("__float__",new PyMethodDescr("__float__",PyComplex.class,0,0,new exposed___float__(null,null))); 76 class exposed___int__ extends PyBuiltinFunctionNarrow { 77 78 private PyComplex self; 79 80 public PyObject getSelf() { 81 return self; 82 } 83 84 exposed___int__(PyComplex self,PyBuiltinFunction.Info info) { 85 super(info); 86 this.self=self; 87 } 88 89 public PyBuiltinFunction makeBound(PyObject self) { 90 return new exposed___int__((PyComplex)self,info); 91 } 92 93 public PyObject __call__() { 94 return self.complex___int__(); 95 } 96 97 public PyObject inst_call(PyObject gself) { 98 PyComplex self=(PyComplex)gself; 99 return self.complex___int__(); 100 } 101 102 } 103 dict.__setitem__("__int__",new PyMethodDescr("__int__",PyComplex.class,0,0,new exposed___int__(null,null))); 104 class exposed___long__ extends PyBuiltinFunctionNarrow { 105 106 private PyComplex self; 107 108 public PyObject getSelf() { 109 return self; 110 } 111 112 exposed___long__(PyComplex self,PyBuiltinFunction.Info info) { 113 super(info); 114 this.self=self; 115 } 116 117 public PyBuiltinFunction makeBound(PyObject self) { 118 return new exposed___long__((PyComplex)self,info); 119 } 120 121 public PyObject __call__() { 122 return self.complex___long__(); 123 } 124 125 public PyObject inst_call(PyObject gself) { 126 PyComplex self=(PyComplex)gself; 127 return self.complex___long__(); 128 } 129 130 } 131 dict.__setitem__("__long__",new PyMethodDescr("__long__",PyComplex.class,0,0,new exposed___long__(null,null))); 132 class exposed___neg__ extends PyBuiltinFunctionNarrow { 133 134 private PyComplex self; 135 136 public PyObject getSelf() { 137 return self; 138 } 139 140 exposed___neg__(PyComplex self,PyBuiltinFunction.Info info) { 141 super(info); 142 this.self=self; 143 } 144 145 public PyBuiltinFunction makeBound(PyObject self) { 146 return new exposed___neg__((PyComplex)self,info); 147 } 148 149 public PyObject __call__() { 150 return self.complex___neg__(); 151 } 152 153 public PyObject inst_call(PyObject gself) { 154 PyComplex self=(PyComplex)gself; 155 return self.complex___neg__(); 156 } 157 158 } 159 dict.__setitem__("__neg__",new PyMethodDescr("__neg__",PyComplex.class,0,0,new exposed___neg__(null,null))); 160 class exposed___pos__ extends PyBuiltinFunctionNarrow { 161 162 private PyComplex self; 163 164 public PyObject getSelf() { 165 return self; 166 } 167 168 exposed___pos__(PyComplex self,PyBuiltinFunction.Info info) { 169 super(info); 170 this.self=self; 171 } 172 173 public PyBuiltinFunction makeBound(PyObject self) { 174 return new exposed___pos__((PyComplex)self,info); 175 } 176 177 public PyObject __call__() { 178 return self.complex___pos__(); 179 } 180 181 public PyObject inst_call(PyObject gself) { 182 PyComplex self=(PyComplex)gself; 183 return self.complex___pos__(); 184 } 185 186 } 187 dict.__setitem__("__pos__",new PyMethodDescr("__pos__",PyComplex.class,0,0,new exposed___pos__(null,null))); 188 class exposed___add__ extends PyBuiltinFunctionNarrow { 189 190 private PyComplex self; 191 192 public PyObject getSelf() { 193 return self; 194 } 195 196 exposed___add__(PyComplex self,PyBuiltinFunction.Info info) { 197 super(info); 198 this.self=self; 199 } 200 201 public PyBuiltinFunction makeBound(PyObject self) { 202 return new exposed___add__((PyComplex)self,info); 203 } 204 205 public PyObject __call__(PyObject arg0) { 206 PyObject ret=self.complex___add__(arg0); 207 if (ret==null) 208 return Py.NotImplemented; 209 return ret; 210 } 211 212 public PyObject inst_call(PyObject gself,PyObject arg0) { 213 PyComplex self=(PyComplex)gself; 214 PyObject ret=self.complex___add__(arg0); 215 if (ret==null) 216 return Py.NotImplemented; 217 return ret; 218 } 219 220 } 221 dict.__setitem__("__add__",new PyMethodDescr("__add__",PyComplex.class,1,1,new exposed___add__(null,null))); 222 class exposed___div__ extends PyBuiltinFunctionNarrow { 223 224 private PyComplex self; 225 226 public PyObject getSelf() { 227 return self; 228 } 229 230 exposed___div__(PyComplex self,PyBuiltinFunction.Info info) { 231 super(info); 232 this.self=self; 233 } 234 235 public PyBuiltinFunction makeBound(PyObject self) { 236 return new exposed___div__((PyComplex)self,info); 237 } 238 239 public PyObject __call__(PyObject arg0) { 240 PyObject ret=self.complex___div__(arg0); 241 if (ret==null) 242 return Py.NotImplemented; 243 return ret; 244 } 245 246 public PyObject inst_call(PyObject gself,PyObject arg0) { 247 PyComplex self=(PyComplex)gself; 248 PyObject ret=self.complex___div__(arg0); 249 if (ret==null) 250 return Py.NotImplemented; 251 return ret; 252 } 253 254 } 255 dict.__setitem__("__div__",new PyMethodDescr("__div__",PyComplex.class,1,1,new exposed___div__(null,null))); 256 class exposed___divmod__ extends PyBuiltinFunctionNarrow { 257 258 private PyComplex self; 259 260 public PyObject getSelf() { 261 return self; 262 } 263 264 exposed___divmod__(PyComplex self,PyBuiltinFunction.Info info) { 265 super(info); 266 this.self=self; 267 } 268 269 public PyBuiltinFunction makeBound(PyObject self) { 270 return new exposed___divmod__((PyComplex)self,info); 271 } 272 273 public PyObject __call__(PyObject arg0) { 274 PyObject ret=self.complex___divmod__(arg0); 275 if (ret==null) 276 return Py.NotImplemented; 277 return ret; 278 } 279 280 public PyObject inst_call(PyObject gself,PyObject arg0) { 281 PyComplex self=(PyComplex)gself; 282 PyObject ret=self.complex___divmod__(arg0); 283 if (ret==null) 284 return Py.NotImplemented; 285 return ret; 286 } 287 288 } 289 dict.__setitem__("__divmod__",new PyMethodDescr("__divmod__",PyComplex.class,1,1,new exposed___divmod__(null,null))); 290 class exposed___floordiv__ extends PyBuiltinFunctionNarrow { 291 292 private PyComplex self; 293 294 public PyObject getSelf() { 295 return self; 296 } 297 298 exposed___floordiv__(PyComplex self,PyBuiltinFunction.Info info) { 299 super(info); 300 this.self=self; 301 } 302 303 public PyBuiltinFunction makeBound(PyObject self) { 304 return new exposed___floordiv__((PyComplex)self,info); 305 } 306 307 public PyObject __call__(PyObject arg0) { 308 PyObject ret=self.complex___floordiv__(arg0); 309 if (ret==null) 310 return Py.NotImplemented; 311 return ret; 312 } 313 314 public PyObject inst_call(PyObject gself,PyObject arg0) { 315 PyComplex self=(PyComplex)gself; 316 PyObject ret=self.complex___floordiv__(arg0); 317 if (ret==null) 318 return Py.NotImplemented; 319 return ret; 320 } 321 322 } 323 dict.__setitem__("__floordiv__",new PyMethodDescr("__floordiv__",PyComplex.class,1,1,new exposed___floordiv__(null,null))); 324 class exposed___mod__ extends PyBuiltinFunctionNarrow { 325 326 private PyComplex self; 327 328 public PyObject getSelf() { 329 return self; 330 } 331 332 exposed___mod__(PyComplex self,PyBuiltinFunction.Info info) { 333 super(info); 334 this.self=self; 335 } 336 337 public PyBuiltinFunction makeBound(PyObject self) { 338 return new exposed___mod__((PyComplex)self,info); 339 } 340 341 public PyObject __call__(PyObject arg0) { 342 PyObject ret=self.complex___mod__(arg0); 343 if (ret==null) 344 return Py.NotImplemented; 345 return ret; 346 } 347 348 public PyObject inst_call(PyObject gself,PyObject arg0) { 349 PyComplex self=(PyComplex)gself; 350 PyObject ret=self.complex___mod__(arg0); 351 if (ret==null) 352 return Py.NotImplemented; 353 return ret; 354 } 355 356 } 357 dict.__setitem__("__mod__",new PyMethodDescr("__mod__",PyComplex.class,1,1,new exposed___mod__(null,null))); 358 class exposed___mul__ extends PyBuiltinFunctionNarrow { 359 360 private PyComplex self; 361 362 public PyObject getSelf() { 363 return self; 364 } 365 366 exposed___mul__(PyComplex self,PyBuiltinFunction.Info info) { 367 super(info); 368 this.self=self; 369 } 370 371 public PyBuiltinFunction makeBound(PyObject self) { 372 return new exposed___mul__((PyComplex)self,info); 373 } 374 375 public PyObject __call__(PyObject arg0) { 376 PyObject ret=self.complex___mul__(arg0); 377 if (ret==null) 378 return Py.NotImplemented; 379 return ret; 380 } 381 382 public PyObject inst_call(PyObject gself,PyObject arg0) { 383 PyComplex self=(PyComplex)gself; 384 PyObject ret=self.complex___mul__(arg0); 385 if (ret==null) 386 return Py.NotImplemented; 387 return ret; 388 } 389 390 } 391 dict.__setitem__("__mul__",new PyMethodDescr("__mul__",PyComplex.class,1,1,new exposed___mul__(null,null))); 392 class exposed___radd__ extends PyBuiltinFunctionNarrow { 393 394 private PyComplex self; 395 396 public PyObject getSelf() { 397 return self; 398 } 399 400 exposed___radd__(PyComplex self,PyBuiltinFunction.Info info) { 401 super(info); 402 this.self=self; 403 } 404 405 public PyBuiltinFunction makeBound(PyObject self) { 406 return new exposed___radd__((PyComplex)self,info); 407 } 408 409 public PyObject __call__(PyObject arg0) { 410 PyObject ret=self.complex___radd__(arg0); 411 if (ret==null) 412 return Py.NotImplemented; 413 return ret; 414 } 415 416 public PyObject inst_call(PyObject gself,PyObject arg0) { 417 PyComplex self=(PyComplex)gself; 418 PyObject ret=self.complex___radd__(arg0); 419 if (ret==null) 420 return Py.NotImplemented; 421 return ret; 422 } 423 424 } 425 dict.__setitem__("__radd__",new PyMethodDescr("__radd__",PyComplex.class,1,1,new exposed___radd__(null,null))); 426 class exposed___rdiv__ extends PyBuiltinFunctionNarrow { 427 428 private PyComplex self; 429 430 public PyObject getSelf() { 431 return self; 432 } 433 434 exposed___rdiv__(PyComplex self,PyBuiltinFunction.Info info) { 435 super(info); 436 this.self=self; 437 } 438 439 public PyBuiltinFunction makeBound(PyObject self) { 440 return new exposed___rdiv__((PyComplex)self,info); 441 } 442 443 public PyObject __call__(PyObject arg0) { 444 PyObject ret=self.complex___rdiv__(arg0); 445 if (ret==null) 446 return Py.NotImplemented; 447 return ret; 448 } 449 450 public PyObject inst_call(PyObject gself,PyObject arg0) { 451 PyComplex self=(PyComplex)gself; 452 PyObject ret=self.complex___rdiv__(arg0); 453 if (ret==null) 454 return Py.NotImplemented; 455 return ret; 456 } 457 458 } 459 dict.__setitem__("__rdiv__",new PyMethodDescr("__rdiv__",PyComplex.class,1,1,new exposed___rdiv__(null,null))); 460 class exposed__rdivmod__ extends PyBuiltinFunctionNarrow { 461 462 private PyComplex self; 463 464 public PyObject getSelf() { 465 return self; 466 } 467 468 exposed__rdivmod__(PyComplex self,PyBuiltinFunction.Info info) { 469 super(info); 470 this.self=self; 471 } 472 473 public PyBuiltinFunction makeBound(PyObject self) { 474 return new exposed__rdivmod__((PyComplex)self,info); 475 } 476 477 public PyObject __call__(PyObject arg0) { 478 PyObject ret=self.complex___rdivmod__(arg0); 479 if (ret==null) 480 return Py.NotImplemented; 481 return ret; 482 } 483 484 public PyObject inst_call(PyObject gself,PyObject arg0) { 485 PyComplex self=(PyComplex)gself; 486 PyObject ret=self.complex___rdivmod__(arg0); 487 if (ret==null) 488 return Py.NotImplemented; 489 return ret; 490 } 491 492 } 493 dict.__setitem__("_rdivmod__",new PyMethodDescr("_rdivmod__",PyComplex.class,1,1,new exposed__rdivmod__(null,null))); 494 class exposed___rfloordiv__ extends PyBuiltinFunctionNarrow { 495 496 private PyComplex self; 497 498 public PyObject getSelf() { 499 return self; 500 } 501 502 exposed___rfloordiv__(PyComplex self,PyBuiltinFunction.Info info) { 503 super(info); 504 this.self=self; 505 } 506 507 public PyBuiltinFunction makeBound(PyObject self) { 508 return new exposed___rfloordiv__((PyComplex)self,info); 509 } 510 511 public PyObject __call__(PyObject arg0) { 512 PyObject ret=self.complex___rfloordiv__(arg0); 513 if (ret==null) 514 return Py.NotImplemented; 515 return ret; 516 } 517 518 public PyObject inst_call(PyObject gself,PyObject arg0) { 519 PyComplex self=(PyComplex)gself; 520 PyObject ret=self.complex___rfloordiv__(arg0); 521 if (ret==null) 522 return Py.NotImplemented; 523 return ret; 524 } 525 526 } 527 dict.__setitem__("__rfloordiv__",new PyMethodDescr("__rfloordiv__",PyComplex.class,1,1,new exposed___rfloordiv__(null,null))); 528 class exposed___rmod__ extends PyBuiltinFunctionNarrow { 529 530 private PyComplex self; 531 532 public PyObject getSelf() { 533 return self; 534 } 535 536 exposed___rmod__(PyComplex self,PyBuiltinFunction.Info info) { 537 super(info); 538 this.self=self; 539 } 540 541 public PyBuiltinFunction makeBound(PyObject self) { 542 return new exposed___rmod__((PyComplex)self,info); 543 } 544 545 public PyObject __call__(PyObject arg0) { 546 PyObject ret=self.complex___rmod__(arg0); 547 if (ret==null) 548 return Py.NotImplemented; 549 return ret; 550 } 551 552 public PyObject inst_call(PyObject gself,PyObject arg0) { 553 PyComplex self=(PyComplex)gself; 554 PyObject ret=self.complex___rmod__(arg0); 555 if (ret==null) 556 return Py.NotImplemented; 557 return ret; 558 } 559 560 } 561 dict.__setitem__("__rmod__",new PyMethodDescr("__rmod__",PyComplex.class,1,1,new exposed___rmod__(null,null))); 562 class exposed___rmul__ extends PyBuiltinFunctionNarrow { 563 564 private PyComplex self; 565 566 public PyObject getSelf() { 567 return self; 568 } 569 570 exposed___rmul__(PyComplex self,PyBuiltinFunction.Info info) { 571 super(info); 572 this.self=self; 573 } 574 575 public PyBuiltinFunction makeBound(PyObject self) { 576 return new exposed___rmul__((PyComplex)self,info); 577 } 578 579 public PyObject __call__(PyObject arg0) { 580 PyObject ret=self.complex___rmul__(arg0); 581 if (ret==null) 582 return Py.NotImplemented; 583 return ret; 584 } 585 586 public PyObject inst_call(PyObject gself,PyObject arg0) { 587 PyComplex self=(PyComplex)gself; 588 PyObject ret=self.complex___rmul__(arg0); 589 if (ret==null) 590 return Py.NotImplemented; 591 return ret; 592 } 593 594 } 595 dict.__setitem__("__rmul__",new PyMethodDescr("__rmul__",PyComplex.class,1,1,new exposed___rmul__(null,null))); 596 class exposed___rpow__ extends PyBuiltinFunctionNarrow { 597 598 private PyComplex self; 599 600 public PyObject getSelf() { 601 return self; 602 } 603 604 exposed___rpow__(PyComplex self,PyBuiltinFunction.Info info) { 605 super(info); 606 this.self=self; 607 } 608 609 public PyBuiltinFunction makeBound(PyObject self) { 610 return new exposed___rpow__((PyComplex)self,info); 611 } 612 613 public PyObject __call__(PyObject arg0) { 614 PyObject ret=self.complex___rpow__(arg0); 615 if (ret==null) 616 return Py.NotImplemented; 617 return ret; 618 } 619 620 public PyObject inst_call(PyObject gself,PyObject arg0) { 621 PyComplex self=(PyComplex)gself; 622 PyObject ret=self.complex___rpow__(arg0); 623 if (ret==null) 624 return Py.NotImplemented; 625 return ret; 626 } 627 628 } 629 dict.__setitem__("__rpow__",new PyMethodDescr("__rpow__",PyComplex.class,1,1,new exposed___rpow__(null,null))); 630 class exposed___rsub__ extends PyBuiltinFunctionNarrow { 631 632 private PyComplex self; 633 634 public PyObject getSelf() { 635 return self; 636 } 637 638 exposed___rsub__(PyComplex self,PyBuiltinFunction.Info info) { 639 super(info); 640 this.self=self; 641 } 642 643 public PyBuiltinFunction makeBound(PyObject self) { 644 return new exposed___rsub__((PyComplex)self,info); 645 } 646 647 public PyObject __call__(PyObject arg0) { 648 PyObject ret=self.complex___rsub__(arg0); 649 if (ret==null) 650 return Py.NotImplemented; 651 return ret; 652 } 653 654 public PyObject inst_call(PyObject gself,PyObject arg0) { 655 PyComplex self=(PyComplex)gself; 656 PyObject ret=self.complex___rsub__(arg0); 657 if (ret==null) 658 return Py.NotImplemented; 659 return ret; 660 } 661 662 } 663 dict.__setitem__("__rsub__",new PyMethodDescr("__rsub__",PyComplex.class,1,1,new exposed___rsub__(null,null))); 664 class exposed___rtruediv__ extends PyBuiltinFunctionNarrow { 665 666 private PyComplex self; 667 668 public PyObject getSelf() { 669 return self; 670 } 671 672 exposed___rtruediv__(PyComplex self,PyBuiltinFunction.Info info) { 673 super(info); 674 this.self=self; 675 } 676 677 public PyBuiltinFunction makeBound(PyObject self) { 678 return new exposed___rtruediv__((PyComplex)self,info); 679 } 680 681 public PyObject __call__(PyObject arg0) { 682 PyObject ret=self.complex___rtruediv__(arg0); 683 if (ret==null) 684 return Py.NotImplemented; 685 return ret; 686 } 687 688 public PyObject inst_call(PyObject gself,PyObject arg0) { 689 PyComplex self=(PyComplex)gself; 690 PyObject ret=self.complex___rtruediv__(arg0); 691 if (ret==null) 692 return Py.NotImplemented; 693 return ret; 694 } 695 696 } 697 dict.__setitem__("__rtruediv__",new PyMethodDescr("__rtruediv__",PyComplex.class,1,1,new exposed___rtruediv__(null,null))); 698 class exposed___sub__ extends PyBuiltinFunctionNarrow { 699 700 private PyComplex self; 701 702 public PyObject getSelf() { 703 return self; 704 } 705 706 exposed___sub__(PyComplex self,PyBuiltinFunction.Info info) { 707 super(info); 708 this.self=self; 709 } 710 711 public PyBuiltinFunction makeBound(PyObject self) { 712 return new exposed___sub__((PyComplex)self,info); 713 } 714 715 public PyObject __call__(PyObject arg0) { 716 PyObject ret=self.complex___sub__(arg0); 717 if (ret==null) 718 return Py.NotImplemented; 719 return ret; 720 } 721 722 public PyObject inst_call(PyObject gself,PyObject arg0) { 723 PyComplex self=(PyComplex)gself; 724 PyObject ret=self.complex___sub__(arg0); 725 if (ret==null) 726 return Py.NotImplemented; 727 return ret; 728 } 729 730 } 731 dict.__setitem__("__sub__",new PyMethodDescr("__sub__",PyComplex.class,1,1,new exposed___sub__(null,null))); 732 class exposed___truediv__ extends PyBuiltinFunctionNarrow { 733 734 private PyComplex self; 735 736 public PyObject getSelf() { 737 return self; 738 } 739 740 exposed___truediv__(PyComplex self,PyBuiltinFunction.Info info) { 741 super(info); 742 this.self=self; 743 } 744 745 public PyBuiltinFunction makeBound(PyObject self) { 746 return new exposed___truediv__((PyComplex)self,info); 747 } 748 749 public PyObject __call__(PyObject arg0) { 750 PyObject ret=self.complex___truediv__(arg0); 751 if (ret==null) 752 return Py.NotImplemented; 753 return ret; 754 } 755 756 public PyObject inst_call(PyObject gself,PyObject arg0) { 757 PyComplex self=(PyComplex)gself; 758 PyObject ret=self.complex___truediv__(arg0); 759 if (ret==null) 760 return Py.NotImplemented; 761 return ret; 762 } 763 764 } 765 dict.__setitem__("__truediv__",new PyMethodDescr("__truediv__",PyComplex.class,1,1,new exposed___truediv__(null,null))); 766 class exposed___pow__ extends PyBuiltinFunctionNarrow { 767 768 private PyComplex self; 769 770 public PyObject getSelf() { 771 return self; 772 } 773 774 exposed___pow__(PyComplex self,PyBuiltinFunction.Info info) { 775 super(info); 776 this.self=self; 777 } 778 779 public PyBuiltinFunction makeBound(PyObject self) { 780 return new exposed___pow__((PyComplex)self,info); 781 } 782 783 public PyObject __call__(PyObject arg0,PyObject arg1) { 784 PyObject ret=self.complex___pow__(arg0,arg1); 785 if (ret==null) 786 return Py.NotImplemented; 787 return ret; 788 } 789 790 public PyObject inst_call(PyObject gself,PyObject arg0,PyObject arg1) { 791 PyComplex self=(PyComplex)gself; 792 PyObject ret=self.complex___pow__(arg0,arg1); 793 if (ret==null) 794 return Py.NotImplemented; 795 return ret; 796 } 797 798 public PyObject __call__(PyObject arg0) { 799 PyObject ret=self.complex___pow__(arg0,null); 800 if (ret==null) 801 return Py.NotImplemented; 802 return ret; 803 } 804 805 public PyObject inst_call(PyObject gself,PyObject arg0) { 806 PyComplex self=(PyComplex)gself; 807 PyObject ret=self.complex___pow__(arg0,null); 808 if (ret==null) 809 return Py.NotImplemented; 810 return ret; 811 } 812 813 } 814 dict.__setitem__("__pow__",new PyMethodDescr("__pow__",PyComplex.class,1,2,new exposed___pow__(null,null))); 815 class exposed_conjugate extends PyBuiltinFunctionNarrow { 816 817 private PyComplex self; 818 819 public PyObject getSelf() { 820 return self; 821 } 822 823 exposed_conjugate(PyComplex self,PyBuiltinFunction.Info info) { 824 super(info); 825 this.self=self; 826 } 827 828 public PyBuiltinFunction makeBound(PyObject self) { 829 return new exposed_conjugate((PyComplex)self,info); 830 } 831 832 public PyObject __call__() { 833 return self.complex_conjugate(); 834 } 835 836 public PyObject inst_call(PyObject gself) { 837 PyComplex self=(PyComplex)gself; 838 return self.complex_conjugate(); 839 } 840 841 } 842 dict.__setitem__("conjugate",new PyMethodDescr("conjugate",PyComplex.class,0,0,new exposed_conjugate(null,null))); 843 class exposed___nonzero__ extends PyBuiltinFunctionNarrow { 844 845 private PyComplex self; 846 847 public PyObject getSelf() { 848 return self; 849 } 850 851 exposed___nonzero__(PyComplex self,PyBuiltinFunction.Info info) { 852 super(info); 853 this.self=self; 854 } 855 856 public PyBuiltinFunction makeBound(PyObject self) { 857 return new exposed___nonzero__((PyComplex)self,info); 858 } 859 860 public PyObject __call__() { 861 return Py.newBoolean(self.complex___nonzero__()); 862 } 863 864 public PyObject inst_call(PyObject gself) { 865 PyComplex self=(PyComplex)gself; 866 return Py.newBoolean(self.complex___nonzero__()); 867 } 868 869 } 870 dict.__setitem__("__nonzero__",new PyMethodDescr("__nonzero__",PyComplex.class,0,0,new exposed___nonzero__(null,null))); 871 class exposed___repr__ extends PyBuiltinFunctionNarrow { 872 873 private PyComplex self; 874 875 public PyObject getSelf() { 876 return self; 877 } 878 879 exposed___repr__(PyComplex self,PyBuiltinFunction.Info info) { 880 super(info); 881 this.self=self; 882 } 883 884 public PyBuiltinFunction makeBound(PyObject self) { 885 return new exposed___repr__((PyComplex)self,info); 886 } 887 888 public PyObject __call__() { 889 return new PyString(self.complex_toString()); 890 } 891 892 public PyObject inst_call(PyObject gself) { 893 PyComplex self=(PyComplex)gself; 894 return new PyString(self.complex_toString()); 895 } 896 897 } 898 dict.__setitem__("__repr__",new PyMethodDescr("__repr__",PyComplex.class,0,0,new exposed___repr__(null,null))); 899 class exposed___str__ extends PyBuiltinFunctionNarrow { 900 901 private PyComplex self; 902 903 public PyObject getSelf() { 904 return self; 905 } 906 907 exposed___str__(PyComplex self,PyBuiltinFunction.Info info) { 908 super(info); 909 this.self=self; 910 } 911 912 public PyBuiltinFunction makeBound(PyObject self) { 913 return new exposed___str__((PyComplex)self,info); 914 } 915 916 public PyObject __call__() { 917 return new PyString(self.complex_toString()); 918 } 919 920 public PyObject inst_call(PyObject gself) { 921 PyComplex self=(PyComplex)gself; 922 return new PyString(self.complex_toString()); 923 } 924 925 } 926 dict.__setitem__("__str__",new PyMethodDescr("__str__",PyComplex.class,0,0,new exposed___str__(null,null))); 927 class exposed___hash__ extends PyBuiltinFunctionNarrow { 928 929 private PyComplex self; 930 931 public PyObject getSelf() { 932 return self; 933 } 934 935 exposed___hash__(PyComplex self,PyBuiltinFunction.Info info) { 936 super(info); 937 this.self=self; 938 } 939 940 public PyBuiltinFunction makeBound(PyObject self) { 941 return new exposed___hash__((PyComplex)self,info); 942 } 943 944 public PyObject __call__() { 945 return Py.newInteger(self.complex_hashCode()); 946 } 947 948 public PyObject inst_call(PyObject gself) { 949 PyComplex self=(PyComplex)gself; 950 return Py.newInteger(self.complex_hashCode()); 951 } 952 953 } 954 dict.__setitem__("__hash__",new PyMethodDescr("__hash__",PyComplex.class,0,0,new exposed___hash__(null,null))); 955 dict.__setitem__("__new__",new PyNewWrapper(PyComplex.class,"__new__",-1,-1) { 956 957 public PyObject new_impl(boolean init,PyType subtype,PyObject[]args,String []keywords) { 958 return complex_new(this,init,subtype,args,keywords); 959 } 960 961 }); 962 } 963 964 public static PyObject complex_new(PyObject new_, boolean init, PyType subtype, 965 PyObject[] args, String [] keywords) { 966 if (args.length == 0) 967 return new PyComplex(0, 0); 968 969 if (args.length > 2) 970 throw Py.TypeError("complex() "+"takes at most 2 arguments (" + 971 args.length + " given)"); 972 973 975 ArgParser ap = new ArgParser("complex", args, keywords, "real", "imag"); 976 PyObject real = ap.getPyObject(0, Py.Zero); 977 PyObject imag = ap.getPyObject(1, null); 978 979 if (imag != null) { 980 if (real instanceof PyString) 981 throw Py.TypeError("complex() " + 982 "can't take second arg if first is a string"); 983 if (imag instanceof PyString) 984 throw Py.TypeError("complex() " + 985 "second arg can't be a string"); 986 } 987 988 PyComplex ret = null; 989 try { 990 ret = real.__complex__(); 991 } catch (PyException pye) { 992 if (!(Py.matchException(pye, Py.AttributeError))) throw pye; 994 } 995 996 try { 997 if (ret == null) 998 ret = new PyComplex(real.__float__().getValue(), 0); 999 if (imag != null) { 1000 if (ret == real) 1001 ret = new PyComplex(ret.real, ret.imag); 1002 if (imag instanceof PyComplex) { 1003 PyComplex c = (PyComplex) imag; 1007 ret.real -= c.imag; 1008 ret.imag += c.real; 1009 } else { 1010 ret.imag += imag.__float__().getValue(); 1012 } 1013 } 1014 return ret; 1015 } catch (PyException pye) { 1016 if (Py.matchException(pye, Py.AttributeError)) { 1018 Object o = (ret == null ? real : imag); 1019 if (!(o instanceof PyInstance)) 1020 throw Py.TypeError("complex() " + 1021 "argument must be a string or a number"); 1022 } 1023 throw pye; 1024 } 1025 } 1026 1027 private static final PyType COMPLEXTYPE = PyType.fromClass(PyComplex.class); 1028 1029 public PyComplex(double r, double i) { 1030 super(COMPLEXTYPE); 1031 real = r; 1032 imag = i; 1033 } 1034 1035 public String safeRepr() throws PyIgnoreMethodTag { 1036 return "'complex' object"; 1037 } 1038 1039 public final PyFloat getReal() { 1040 return Py.newFloat(real); 1041 } 1042 1043 public final PyFloat getImag() { 1044 return Py.newFloat(imag); 1045 } 1046 1047 public static String toString(double value) { 1048 if (value == Math.floor(value) && 1049 value <= Long.MAX_VALUE && value >= Long.MIN_VALUE) { 1050 return Long.toString((long)value); 1051 } else { 1052 return Double.toString(value); 1053 } 1054 } 1055 1056 public String toString() { 1057 return complex_toString(); 1058 } 1059 1060 final String complex_toString() { 1061 if (real == 0.) { 1062 return toString(imag)+"j"; 1063 } else { 1064 if (imag >= 0) { 1065 return "("+toString(real)+"+"+toString(imag)+"j)"; 1066 } else { 1067 return "("+toString(real)+"-"+toString(-imag)+"j)"; 1068 } 1069 } 1070 } 1071 1072 public int hashCode() { 1073 return complex_hashCode(); 1074 } 1075 1076 final int complex_hashCode() { 1077 if (imag == 0) { 1078 return new PyFloat(real).hashCode(); 1079 } else { 1080 long v = Double.doubleToLongBits(real) ^ 1081 Double.doubleToLongBits(imag); 1082 return (int)v ^ (int)(v >> 32); 1083 } 1084 } 1085 1086 public boolean __nonzero__() { 1087 return complex___nonzero__(); 1088 } 1089 1090 final boolean complex___nonzero__() { 1091 return real != 0 && imag != 0; 1092 } 1093 1094 1097 1098 public int __cmp__(PyObject other) { 1099 return complex___cmp__(other); 1100 } 1101 1102 final int complex___cmp__(PyObject other) { 1103 if (!canCoerce(other)) 1104 return -2; 1105 PyComplex c = coerce(other); 1106 double oreal = c.real; 1107 double oimag = c.imag; 1108 if (real == oreal && imag == oimag) 1109 return 0; 1110 if (real != oreal) { 1111 return real < oreal ? -1 : 1; 1112 } else { 1113 return imag < oimag ? -1 : 1; 1114 } 1115 } 1116 1117 1120 public PyObject __eq__(PyObject other) { 1121 return complex___eq__(other); 1122 } 1123 1124 final PyObject complex___eq__(PyObject other) { 1125 if (!canCoerce(other)) 1126 return null; 1127 PyComplex c = coerce(other); 1128 return Py.newBoolean(real == c.real && imag == c.imag); 1129 } 1130 1131 1134 public PyObject __ne__(PyObject other) { 1135 return complex___ne__(other); 1136 } 1137 1138 final PyObject complex___ne__(PyObject other) { 1139 if (!canCoerce(other)) 1140 return null; 1141 PyComplex c = coerce(other); 1142 return Py.newBoolean(real != c.real || imag != c.imag); 1143 } 1144 1145 private PyObject unsupported_comparison(PyObject other) { 1146 if (!canCoerce(other)) 1147 return null; 1148 throw Py.TypeError("cannot compare complex numbers using <, <=, >, >="); 1149 } 1150 1151 public PyObject __ge__(PyObject other) { 1152 return complex___ge__(other); 1153 } 1154 1155 final PyObject complex___ge__(PyObject other) { 1156 return unsupported_comparison(other); 1157 } 1158 1159 public PyObject __gt__(PyObject other) { 1160 return complex___gt__(other); 1161 } 1162 1163 final PyObject complex___gt__(PyObject other) { 1164 return unsupported_comparison(other); 1165 } 1166 1167 public PyObject __le__(PyObject other) { 1168 return complex___le__(other); 1169 } 1170 1171 final PyObject complex___le__(PyObject other) { 1172 return unsupported_comparison(other); 1173 } 1174 1175 public PyObject __lt__(PyObject other) { 1176 return complex___lt__(other); 1177 } 1178 1179 final PyObject complex___lt__(PyObject other) { 1180 return unsupported_comparison(other); 1181 } 1182 1183 1184 public Object __coerce_ex__(PyObject other) { 1185 if (other instanceof PyComplex) 1186 return other; 1187 if (other instanceof PyFloat) 1188 return new PyComplex(((PyFloat)other).getValue(), 0); 1189 if (other instanceof PyInteger) 1190 return new PyComplex((double)((PyInteger)other).getValue(), 0); 1191 if (other instanceof PyLong) 1192 return new PyComplex(((PyLong)other).doubleValue(), 0); 1193 return Py.None; 1194 } 1195 1196 private final boolean canCoerce(PyObject other) { 1197 return other instanceof PyComplex || 1198 other instanceof PyFloat || 1199 other instanceof PyInteger || 1200 other instanceof PyLong; 1201 } 1202 1203 private final PyComplex coerce(PyObject other) { 1204 if (other instanceof PyComplex) 1205 return (PyComplex) other; 1206 if (other instanceof PyFloat) 1207 return new PyComplex(((PyFloat)other).getValue(), 0); 1208 if (other instanceof PyInteger) 1209 return new PyComplex((double)((PyInteger)other).getValue(), 0); 1210 if (other instanceof PyLong) 1211 return new PyComplex(((PyLong)other).doubleValue(), 0); 1212 throw Py.TypeError("xxx"); 1213 } 1214 1215 public PyObject __add__(PyObject right) { 1216 return complex___add__(right); 1217 } 1218 1219 final PyObject complex___add__(PyObject right) { 1220 if (!canCoerce(right)) 1221 return null; 1222 PyComplex c = coerce(right); 1223 return new PyComplex(real+c.real, imag+c.imag); 1224 } 1225 1226 public PyObject __radd__(PyObject left) { 1227 return complex___radd__(left); 1228 } 1229 1230 final PyObject complex___radd__(PyObject left) { 1231 return __add__(left); 1232 } 1233 1234 private final static PyObject _sub(PyComplex o1, PyComplex o2) { 1235 return new PyComplex(o1.real-o2.real, o1.imag-o2.imag); 1236 } 1237 1238 public PyObject __sub__(PyObject right) { 1239 return complex___sub__(right); 1240 } 1241 1242 final PyObject complex___sub__(PyObject right) { 1243 if (!canCoerce(right)) 1244 return null; 1245 return _sub(this, coerce(right)); 1246 } 1247 1248 public PyObject __rsub__(PyObject left) { 1249 return complex___rsub__(left); 1250 } 1251 1252 final PyObject complex___rsub__(PyObject left) { 1253 if (!canCoerce(left)) 1254 return null; 1255 return _sub(coerce(left), this); 1256 } 1257 1258 private final static PyObject _mul(PyComplex o1, PyComplex o2) { 1259 return new PyComplex(o1.real*o2.real-o1.imag*o2.imag, 1260 o1.real*o2.imag+o1.imag*o2.real); 1261 } 1262 1263 public PyObject __mul__(PyObject right) { 1264 return complex___mul__(right); 1265 } 1266 1267 final PyObject complex___mul__(PyObject right) { 1268 if (!canCoerce(right)) 1269 return null; 1270 return _mul(this, coerce(right)); 1271 } 1272 1273 public PyObject __rmul__(PyObject left) { 1274 return complex___rmul__(left); 1275 } 1276 1277 final PyObject complex___rmul__(PyObject left) { 1278 if (!canCoerce(left)) 1279 return null; 1280 return _mul(coerce(left), this); 1281 } 1282 1283 private final static PyObject _div(PyComplex a, PyComplex b) { 1284 double abs_breal = b.real < 0 ? -b.real : b.real; 1285 double abs_bimag = b.imag < 0 ? -b.imag : b.imag; 1286 if (abs_breal >= abs_bimag) { 1287 if (abs_breal == 0.0) { 1289 throw Py.ZeroDivisionError("complex division"); 1290 } 1291 double ratio = b.imag / b.real; 1292 double denom = b.real + b.imag * ratio; 1293 return new PyComplex((a.real + a.imag * ratio) / denom, 1294 (a.imag - a.real * ratio) / denom); 1295 } else { 1296 1297 double ratio = b.real / b.imag; 1298 double denom = b.real * ratio + b.imag; 1299 return new PyComplex((a.real * ratio + a.imag) / denom, 1300 (a.imag * ratio - a.real) / denom); 1301 } 1302 } 1303 1304 public PyObject __div__(PyObject right) { 1305 return complex___div__(right); 1306 } 1307 1308 final PyObject complex___div__(PyObject right) { 1309 if (!canCoerce(right)) 1310 return null; 1311 if (Options.divisionWarning >= 2) 1312 Py.warning(Py.DeprecationWarning, "classic complex division"); 1313 return _div(this, coerce(right)); 1314 } 1315 1316 public PyObject __rdiv__(PyObject left) { 1317 return complex___rdiv__(left); 1318 } 1319 1320 final PyObject complex___rdiv__(PyObject left) { 1321 if (!canCoerce(left)) 1322 return null; 1323 if (Options.divisionWarning >= 2) 1324 Py.warning(Py.DeprecationWarning, "classic complex division"); 1325 return _div(coerce(left), this); 1326 } 1327 1328 public PyObject __floordiv__(PyObject right) { 1329 return complex___floordiv__(right); 1330 } 1331 1332 final PyObject complex___floordiv__(PyObject right) { 1333 if (!canCoerce(right)) 1334 return null; 1335 return _divmod(this, coerce(right)).__finditem__(0); 1336 } 1337 1338 public PyObject __rfloordiv__(PyObject left) { 1339 return complex___floordiv__(left); 1340 } 1341 1342 final PyObject complex___rfloordiv__(PyObject left) { 1343 if (!canCoerce(left)) 1344 return null; 1345 return _divmod(coerce(left), this).__finditem__(0); 1346 } 1347 1348 public PyObject __truediv__(PyObject right) { 1349 return complex___truediv__(right); 1350 } 1351 1352 final PyObject complex___truediv__(PyObject right) { 1353 if (!canCoerce(right)) 1354 return null; 1355 return _div(this, coerce(right)); 1356 } 1357 1358 public PyObject __rtruediv__(PyObject left) { 1359 return complex___rtruediv__(left); 1360 } 1361 1362 final PyObject complex___rtruediv__(PyObject left) { 1363 if (!canCoerce(left)) 1364 return null; 1365 return _div(coerce(left), this); 1366 } 1367 1368 public PyObject __mod__(PyObject right) { 1369 return complex___mod__(right); 1370 } 1371 1372 final PyObject complex___mod__(PyObject right) { 1373 if (!canCoerce(right)) 1374 return null; 1375 return _mod(this, coerce(right)); 1376 } 1377 1378 public PyObject __rmod__(PyObject left) { 1379 return complex___rmod__(left); 1380 } 1381 1382 final PyObject complex___rmod__(PyObject left) { 1383 if (!canCoerce(left)) 1384 return null; 1385 return _mod(coerce(left), this); 1386 } 1387 1388 private static PyObject _mod(PyComplex value, PyComplex right) { 1389 PyComplex z = (PyComplex) _div(value, right); 1390 1391 z.real = Math.floor(z.real); 1392 z.imag = 0.0; 1393 1394 return value.__sub__(z.__mul__(right)); 1395 } 1396 1397 public PyObject __divmod__(PyObject right) { 1398 return complex___divmod__(right); 1399 } 1400 1401 final PyObject complex___divmod__(PyObject right) { 1402 if (!canCoerce(right)) 1403 return null; 1404 return _divmod(this, coerce(right)); 1405 } 1406 1407 public PyObject __rdivmod__(PyObject left) { 1408 return complex___rdivmod__(left); 1409 } 1410 1411 final PyObject complex___rdivmod__(PyObject left) { 1412 if (!canCoerce(left)) 1413 return null; 1414 return _divmod(coerce(left), this); 1415 } 1416 1417 private static PyObject _divmod(PyComplex value, PyComplex right) { 1418 PyComplex z = (PyComplex) _div(value, right); 1419 1420 z.real = Math.floor(z.real); 1421 z.imag = 0.0; 1422 1423 return new PyTuple(new PyObject[] 1424 { z, value.__sub__(z.__mul__(right))}); 1425 } 1426 1427 1428 private static PyObject ipow(PyComplex value, int iexp) { 1429 int pow = iexp; 1430 if (pow < 0) pow = -pow; 1431 1432 double xr = value.real; 1433 double xi = value.imag; 1434 1435 double zr = 1; 1436 double zi = 0; 1437 1438 double tmp; 1439 1440 while (pow > 0) { 1441 if ((pow & 0x1) != 0) { 1442 tmp = zr*xr - zi*xi; 1443 zi = zi*xr + zr*xi; 1444 zr = tmp; 1445 } 1446 pow >>= 1; 1447 if (pow == 0) 1448 break; 1449 tmp = xr*xr - xi*xi; 1450 xi = xr*xi*2; 1451 xr = tmp; 1452 } 1453 1454 PyComplex ret = new PyComplex(zr, zi); 1455 1456 if (iexp < 0) 1457 return new PyComplex(1,0).__div__(ret); 1458 return ret; 1459 } 1460 1461 public PyObject __pow__(PyObject right, PyObject modulo) { 1462 return complex___pow__(right, modulo); 1463 } 1464 1465 final PyObject complex___pow__(PyObject right, PyObject modulo) { 1466 if (modulo != null) { 1467 throw Py.ValueError("complex modulo"); 1468 } 1469 if (!canCoerce(right)) 1470 return null; 1471 return _pow(this, coerce(right)); 1472 } 1473 1474 public PyObject __rpow__(PyObject left) { 1475 return complex___rpow__(left); 1476 } 1477 1478 final PyObject complex___rpow__(PyObject left) { 1479 if (!canCoerce(left)) 1480 return null; 1481 return _pow(coerce(left), this); 1482 } 1483 1484 public static PyObject _pow(PyComplex value, PyComplex right) { 1485 double xr = value.real; 1486 double xi = value.imag; 1487 double yr = right.real; 1488 double yi = right.imag; 1489 1490 if (yr == 0 && yi == 0) { 1491 return new PyComplex(1, 0); 1492 } 1493 1494 if (xr == 0 && xi == 0) { 1495 if (yi != 0 || yr < 0) { 1496 throw Py.ValueError("0.0 to a negative or complex power"); 1497 } 1498 } 1499 1500 int iexp = (int)yr; 1502 if (yi == 0 && yr == (double)iexp && iexp >= -128 && iexp <= 128) { 1503 return ipow(value, iexp); 1504 } 1505 1506 double abs = ExtraMath.hypot(xr, xi); 1507 double len = Math.pow(abs, yr); 1508 1509 double at = Math.atan2(xi, xr); 1510 double phase = at*yr; 1511 if (yi != 0) { 1512 len /= Math.exp(at*yi); 1513 phase += yi*Math.log(abs); 1514 } 1515 return new PyComplex(len*Math.cos(phase), len*Math.sin(phase)); 1516 } 1517 1518 public PyObject __neg__() { 1519 return complex___neg__(); 1520 } 1521 1522 final PyObject complex___neg__() { 1523 return new PyComplex(-real, -imag); 1524 } 1525 1526 public PyObject __pos__() { 1527 return complex___pos__(); 1528 } 1529 1530 final PyObject complex___pos__() { 1531 return this; 1532 } 1533 1534 public PyObject __invert__() { 1535 throw Py.TypeError("bad operand type for unary ~"); 1536 } 1537 1538 public PyObject __abs__() { 1539 return complex___abs__(); 1540 } 1541 1542 final PyObject complex___abs__() { 1543 return new PyFloat(ExtraMath.hypot(real, imag)); 1544 } 1545 1546 public PyObject __int__() { 1547 return complex___int__(); 1548 } 1549 1550 final PyInteger complex___int__() { 1551 throw Py.TypeError( 1552 "can't convert complex to int; use e.g. int(abs(z))"); 1553 } 1554 1555 public PyLong __long__() { 1556 return complex___long__(); 1557 } 1558 1559 final PyLong complex___long__() { 1560 throw Py.TypeError( 1561 "can't convert complex to long; use e.g. long(abs(z))"); 1562 } 1563 1564 public PyFloat __float__() { 1565 return complex___float__(); 1566 } 1567 1568 final PyFloat complex___float__() { 1569 throw Py.TypeError("can't convert complex to float; use e.g. abs(z)"); 1570 } 1571 1572 public PyComplex __complex__() { 1573 return this; 1574 } 1575 1576 public PyComplex conjugate() { 1577 return complex_conjugate(); 1578 } 1579 1580 final PyComplex complex_conjugate() { 1581 return new PyComplex(real, -imag); 1582 } 1583 1584 public boolean isMappingType() { return false; } 1585 public boolean isSequenceType() { return false; } 1586} 1587 | Popular Tags |