Source Code Cross Referenced for PyComplex.java in  » Testing » Marathon » org » python » core » Java Source Code / Java DocumentationJava Source Code and Java Documentation

Java Source Code / Java Documentation
1. 6.0 JDK Core
2. 6.0 JDK Modules
3. 6.0 JDK Modules com.sun
4. 6.0 JDK Modules com.sun.java
5. 6.0 JDK Modules sun
6. 6.0 JDK Platform
7. Ajax
8. Apache Harmony Java SE
9. Aspect oriented
10. Authentication Authorization
11. Blogger System
12. Build
13. Byte Code
14. Cache
15. Chart
16. Chat
17. Code Analyzer
18. Collaboration
19. Content Management System
20. Database Client
21. Database DBMS
22. Database JDBC Connection Pool
23. Database ORM
24. Development
25. EJB Server geronimo
26. EJB Server GlassFish
27. EJB Server JBoss 4.2.1
28. EJB Server resin 3.1.5
29. ERP CRM Financial
30. ESB
31. Forum
32. GIS
33. Graphic Library
34. Groupware
35. HTML Parser
36. IDE
37. IDE Eclipse
38. IDE Netbeans
39. Installer
40. Internationalization Localization
41. Inversion of Control
42. Issue Tracking
43. J2EE
44. JBoss
45. JMS
46. JMX
47. Library
48. Mail Clients
49. Net
50. Parser
51. PDF
52. Portal
53. Profiler
54. Project Management
55. Report
56. RSS RDF
57. Rule Engine
58. Science
59. Scripting
60. Search Engine
61. Security
62. Sevlet Container
63. Source Control
64. Swing Library
65. Template Engine
66. Test Coverage
67. Testing
68. UML
69. Web Crawler
70. Web Framework
71. Web Mail
72. Web Server
73. Web Services
74. Web Services apache cxf 2.0.1
75. Web Services AXIS2
76. Wiki Engine
77. Workflow Engines
78. XML
79. XML UI
Java
Java Tutorial
Java Open Source
Jar File Download
Java Articles
Java Products
Java by API
Photoshop Tutorials
Maya Tutorials
Flash Tutorials
3ds-Max Tutorials
Illustrator Tutorials
GIMP Tutorials
C# / C Sharp
C# / CSharp Tutorial
C# / CSharp Open Source
ASP.Net
ASP.NET Tutorial
JavaScript DHTML
JavaScript Tutorial
JavaScript Reference
HTML / CSS
HTML CSS Reference
C / ANSI-C
C Tutorial
C++
C++ Tutorial
Ruby
PHP
Python
Python Tutorial
Python Open Source
SQL Server / T-SQL
SQL Server / T-SQL Tutorial
Oracle PL / SQL
Oracle PL/SQL Tutorial
PostgreSQL
SQL / MySQL
MySQL Tutorial
VB.Net
VB.Net Tutorial
Flash / Flex / ActionScript
VBA / Excel / Access / Word
XML
XML Tutorial
Microsoft Office PowerPoint 2007 Tutorial
Microsoft Office Excel 2007 Tutorial
Microsoft Office Word 2007 Tutorial
Java Source Code / Java Documentation » Testing » Marathon » org.python.core 
Source Cross Referenced  Class Diagram Java Document (Java Doc) 


0001:        // Copyright (c) Corporation for National Research Initiatives
0002:        package org.python.core;
0003:
0004:        /**
0005:         * A builtin python complex number
0006:         */
0007:
0008:        public class PyComplex extends PyObject {
0009:            public double real, imag;
0010:
0011:            static PyComplex J = new PyComplex(0, 1.);
0012:
0013:            //~ BEGIN GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0014:            /* type info */
0015:
0016:            public static final String exposed_name = "complex";
0017:
0018:            public static void typeSetup(PyObject dict, PyType.Newstyle marker) {
0019:                dict.__setitem__("imag", new PyGetSetDescr("imag",
0020:                        PyComplex.class, "getImag", null, null));
0021:                dict.__setitem__("real", new PyGetSetDescr("real",
0022:                        PyComplex.class, "getReal", null, null));
0023:                class exposed___abs__ extends PyBuiltinMethodNarrow {
0024:
0025:                    exposed___abs__(PyObject self, PyBuiltinFunction.Info info) {
0026:                        super (self, info);
0027:                    }
0028:
0029:                    public PyBuiltinFunction bind(PyObject self) {
0030:                        return new exposed___abs__(self, info);
0031:                    }
0032:
0033:                    public PyObject __call__() {
0034:                        return ((PyComplex) self).complex___abs__();
0035:                    }
0036:
0037:                }
0038:                dict
0039:                        .__setitem__("__abs__", new PyMethodDescr("__abs__",
0040:                                PyComplex.class, 0, 0, new exposed___abs__(
0041:                                        null, null)));
0042:                class exposed___float__ extends PyBuiltinMethodNarrow {
0043:
0044:                    exposed___float__(PyObject self, PyBuiltinFunction.Info info) {
0045:                        super (self, info);
0046:                    }
0047:
0048:                    public PyBuiltinFunction bind(PyObject self) {
0049:                        return new exposed___float__(self, info);
0050:                    }
0051:
0052:                    public PyObject __call__() {
0053:                        return ((PyComplex) self).complex___float__();
0054:                    }
0055:
0056:                }
0057:                dict.__setitem__("__float__", new PyMethodDescr("__float__",
0058:                        PyComplex.class, 0, 0,
0059:                        new exposed___float__(null, null)));
0060:                class exposed___int__ extends PyBuiltinMethodNarrow {
0061:
0062:                    exposed___int__(PyObject self, PyBuiltinFunction.Info info) {
0063:                        super (self, info);
0064:                    }
0065:
0066:                    public PyBuiltinFunction bind(PyObject self) {
0067:                        return new exposed___int__(self, info);
0068:                    }
0069:
0070:                    public PyObject __call__() {
0071:                        return ((PyComplex) self).complex___int__();
0072:                    }
0073:
0074:                }
0075:                dict
0076:                        .__setitem__("__int__", new PyMethodDescr("__int__",
0077:                                PyComplex.class, 0, 0, new exposed___int__(
0078:                                        null, null)));
0079:                class exposed___long__ extends PyBuiltinMethodNarrow {
0080:
0081:                    exposed___long__(PyObject self, PyBuiltinFunction.Info info) {
0082:                        super (self, info);
0083:                    }
0084:
0085:                    public PyBuiltinFunction bind(PyObject self) {
0086:                        return new exposed___long__(self, info);
0087:                    }
0088:
0089:                    public PyObject __call__() {
0090:                        return ((PyComplex) self).complex___long__();
0091:                    }
0092:
0093:                }
0094:                dict.__setitem__("__long__",
0095:                        new PyMethodDescr("__long__", PyComplex.class, 0, 0,
0096:                                new exposed___long__(null, null)));
0097:                class exposed___neg__ extends PyBuiltinMethodNarrow {
0098:
0099:                    exposed___neg__(PyObject self, PyBuiltinFunction.Info info) {
0100:                        super (self, info);
0101:                    }
0102:
0103:                    public PyBuiltinFunction bind(PyObject self) {
0104:                        return new exposed___neg__(self, info);
0105:                    }
0106:
0107:                    public PyObject __call__() {
0108:                        return ((PyComplex) self).complex___neg__();
0109:                    }
0110:
0111:                }
0112:                dict
0113:                        .__setitem__("__neg__", new PyMethodDescr("__neg__",
0114:                                PyComplex.class, 0, 0, new exposed___neg__(
0115:                                        null, null)));
0116:                class exposed___pos__ extends PyBuiltinMethodNarrow {
0117:
0118:                    exposed___pos__(PyObject self, PyBuiltinFunction.Info info) {
0119:                        super (self, info);
0120:                    }
0121:
0122:                    public PyBuiltinFunction bind(PyObject self) {
0123:                        return new exposed___pos__(self, info);
0124:                    }
0125:
0126:                    public PyObject __call__() {
0127:                        return ((PyComplex) self).complex___pos__();
0128:                    }
0129:
0130:                }
0131:                dict
0132:                        .__setitem__("__pos__", new PyMethodDescr("__pos__",
0133:                                PyComplex.class, 0, 0, new exposed___pos__(
0134:                                        null, null)));
0135:                class exposed___add__ extends PyBuiltinMethodNarrow {
0136:
0137:                    exposed___add__(PyObject self, PyBuiltinFunction.Info info) {
0138:                        super (self, info);
0139:                    }
0140:
0141:                    public PyBuiltinFunction bind(PyObject self) {
0142:                        return new exposed___add__(self, info);
0143:                    }
0144:
0145:                    public PyObject __call__(PyObject arg0) {
0146:                        PyObject ret = ((PyComplex) self).complex___add__(arg0);
0147:                        if (ret == null)
0148:                            return Py.NotImplemented;
0149:                        return ret;
0150:                    }
0151:
0152:                }
0153:                dict
0154:                        .__setitem__("__add__", new PyMethodDescr("__add__",
0155:                                PyComplex.class, 1, 1, new exposed___add__(
0156:                                        null, null)));
0157:                class exposed___div__ extends PyBuiltinMethodNarrow {
0158:
0159:                    exposed___div__(PyObject self, PyBuiltinFunction.Info info) {
0160:                        super (self, info);
0161:                    }
0162:
0163:                    public PyBuiltinFunction bind(PyObject self) {
0164:                        return new exposed___div__(self, info);
0165:                    }
0166:
0167:                    public PyObject __call__(PyObject arg0) {
0168:                        PyObject ret = ((PyComplex) self).complex___div__(arg0);
0169:                        if (ret == null)
0170:                            return Py.NotImplemented;
0171:                        return ret;
0172:                    }
0173:
0174:                }
0175:                dict
0176:                        .__setitem__("__div__", new PyMethodDescr("__div__",
0177:                                PyComplex.class, 1, 1, new exposed___div__(
0178:                                        null, null)));
0179:                class exposed___divmod__ extends PyBuiltinMethodNarrow {
0180:
0181:                    exposed___divmod__(PyObject self,
0182:                            PyBuiltinFunction.Info info) {
0183:                        super (self, info);
0184:                    }
0185:
0186:                    public PyBuiltinFunction bind(PyObject self) {
0187:                        return new exposed___divmod__(self, info);
0188:                    }
0189:
0190:                    public PyObject __call__(PyObject arg0) {
0191:                        PyObject ret = ((PyComplex) self)
0192:                                .complex___divmod__(arg0);
0193:                        if (ret == null)
0194:                            return Py.NotImplemented;
0195:                        return ret;
0196:                    }
0197:
0198:                }
0199:                dict.__setitem__("__divmod__", new PyMethodDescr("__divmod__",
0200:                        PyComplex.class, 1, 1, new exposed___divmod__(null,
0201:                                null)));
0202:                class exposed___floordiv__ extends PyBuiltinMethodNarrow {
0203:
0204:                    exposed___floordiv__(PyObject self,
0205:                            PyBuiltinFunction.Info info) {
0206:                        super (self, info);
0207:                    }
0208:
0209:                    public PyBuiltinFunction bind(PyObject self) {
0210:                        return new exposed___floordiv__(self, info);
0211:                    }
0212:
0213:                    public PyObject __call__(PyObject arg0) {
0214:                        PyObject ret = ((PyComplex) self)
0215:                                .complex___floordiv__(arg0);
0216:                        if (ret == null)
0217:                            return Py.NotImplemented;
0218:                        return ret;
0219:                    }
0220:
0221:                }
0222:                dict.__setitem__("__floordiv__", new PyMethodDescr(
0223:                        "__floordiv__", PyComplex.class, 1, 1,
0224:                        new exposed___floordiv__(null, null)));
0225:                class exposed___mod__ extends PyBuiltinMethodNarrow {
0226:
0227:                    exposed___mod__(PyObject self, PyBuiltinFunction.Info info) {
0228:                        super (self, info);
0229:                    }
0230:
0231:                    public PyBuiltinFunction bind(PyObject self) {
0232:                        return new exposed___mod__(self, info);
0233:                    }
0234:
0235:                    public PyObject __call__(PyObject arg0) {
0236:                        PyObject ret = ((PyComplex) self).complex___mod__(arg0);
0237:                        if (ret == null)
0238:                            return Py.NotImplemented;
0239:                        return ret;
0240:                    }
0241:
0242:                }
0243:                dict
0244:                        .__setitem__("__mod__", new PyMethodDescr("__mod__",
0245:                                PyComplex.class, 1, 1, new exposed___mod__(
0246:                                        null, null)));
0247:                class exposed___mul__ extends PyBuiltinMethodNarrow {
0248:
0249:                    exposed___mul__(PyObject self, PyBuiltinFunction.Info info) {
0250:                        super (self, info);
0251:                    }
0252:
0253:                    public PyBuiltinFunction bind(PyObject self) {
0254:                        return new exposed___mul__(self, info);
0255:                    }
0256:
0257:                    public PyObject __call__(PyObject arg0) {
0258:                        PyObject ret = ((PyComplex) self).complex___mul__(arg0);
0259:                        if (ret == null)
0260:                            return Py.NotImplemented;
0261:                        return ret;
0262:                    }
0263:
0264:                }
0265:                dict
0266:                        .__setitem__("__mul__", new PyMethodDescr("__mul__",
0267:                                PyComplex.class, 1, 1, new exposed___mul__(
0268:                                        null, null)));
0269:                class exposed___radd__ extends PyBuiltinMethodNarrow {
0270:
0271:                    exposed___radd__(PyObject self, PyBuiltinFunction.Info info) {
0272:                        super (self, info);
0273:                    }
0274:
0275:                    public PyBuiltinFunction bind(PyObject self) {
0276:                        return new exposed___radd__(self, info);
0277:                    }
0278:
0279:                    public PyObject __call__(PyObject arg0) {
0280:                        PyObject ret = ((PyComplex) self)
0281:                                .complex___radd__(arg0);
0282:                        if (ret == null)
0283:                            return Py.NotImplemented;
0284:                        return ret;
0285:                    }
0286:
0287:                }
0288:                dict.__setitem__("__radd__",
0289:                        new PyMethodDescr("__radd__", PyComplex.class, 1, 1,
0290:                                new exposed___radd__(null, null)));
0291:                class exposed___rdiv__ extends PyBuiltinMethodNarrow {
0292:
0293:                    exposed___rdiv__(PyObject self, PyBuiltinFunction.Info info) {
0294:                        super (self, info);
0295:                    }
0296:
0297:                    public PyBuiltinFunction bind(PyObject self) {
0298:                        return new exposed___rdiv__(self, info);
0299:                    }
0300:
0301:                    public PyObject __call__(PyObject arg0) {
0302:                        PyObject ret = ((PyComplex) self)
0303:                                .complex___rdiv__(arg0);
0304:                        if (ret == null)
0305:                            return Py.NotImplemented;
0306:                        return ret;
0307:                    }
0308:
0309:                }
0310:                dict.__setitem__("__rdiv__",
0311:                        new PyMethodDescr("__rdiv__", PyComplex.class, 1, 1,
0312:                                new exposed___rdiv__(null, null)));
0313:                class exposed___rdivmod__ extends PyBuiltinMethodNarrow {
0314:
0315:                    exposed___rdivmod__(PyObject self,
0316:                            PyBuiltinFunction.Info info) {
0317:                        super (self, info);
0318:                    }
0319:
0320:                    public PyBuiltinFunction bind(PyObject self) {
0321:                        return new exposed___rdivmod__(self, info);
0322:                    }
0323:
0324:                    public PyObject __call__(PyObject arg0) {
0325:                        PyObject ret = ((PyComplex) self)
0326:                                .complex___rdivmod__(arg0);
0327:                        if (ret == null)
0328:                            return Py.NotImplemented;
0329:                        return ret;
0330:                    }
0331:
0332:                }
0333:                dict.__setitem__("__rdivmod__", new PyMethodDescr(
0334:                        "__rdivmod__", PyComplex.class, 1, 1,
0335:                        new exposed___rdivmod__(null, null)));
0336:                class exposed___rfloordiv__ extends PyBuiltinMethodNarrow {
0337:
0338:                    exposed___rfloordiv__(PyObject self,
0339:                            PyBuiltinFunction.Info info) {
0340:                        super (self, info);
0341:                    }
0342:
0343:                    public PyBuiltinFunction bind(PyObject self) {
0344:                        return new exposed___rfloordiv__(self, info);
0345:                    }
0346:
0347:                    public PyObject __call__(PyObject arg0) {
0348:                        PyObject ret = ((PyComplex) self)
0349:                                .complex___rfloordiv__(arg0);
0350:                        if (ret == null)
0351:                            return Py.NotImplemented;
0352:                        return ret;
0353:                    }
0354:
0355:                }
0356:                dict.__setitem__("__rfloordiv__", new PyMethodDescr(
0357:                        "__rfloordiv__", PyComplex.class, 1, 1,
0358:                        new exposed___rfloordiv__(null, null)));
0359:                class exposed___rmod__ extends PyBuiltinMethodNarrow {
0360:
0361:                    exposed___rmod__(PyObject self, PyBuiltinFunction.Info info) {
0362:                        super (self, info);
0363:                    }
0364:
0365:                    public PyBuiltinFunction bind(PyObject self) {
0366:                        return new exposed___rmod__(self, info);
0367:                    }
0368:
0369:                    public PyObject __call__(PyObject arg0) {
0370:                        PyObject ret = ((PyComplex) self)
0371:                                .complex___rmod__(arg0);
0372:                        if (ret == null)
0373:                            return Py.NotImplemented;
0374:                        return ret;
0375:                    }
0376:
0377:                }
0378:                dict.__setitem__("__rmod__",
0379:                        new PyMethodDescr("__rmod__", PyComplex.class, 1, 1,
0380:                                new exposed___rmod__(null, null)));
0381:                class exposed___rmul__ extends PyBuiltinMethodNarrow {
0382:
0383:                    exposed___rmul__(PyObject self, PyBuiltinFunction.Info info) {
0384:                        super (self, info);
0385:                    }
0386:
0387:                    public PyBuiltinFunction bind(PyObject self) {
0388:                        return new exposed___rmul__(self, info);
0389:                    }
0390:
0391:                    public PyObject __call__(PyObject arg0) {
0392:                        PyObject ret = ((PyComplex) self)
0393:                                .complex___rmul__(arg0);
0394:                        if (ret == null)
0395:                            return Py.NotImplemented;
0396:                        return ret;
0397:                    }
0398:
0399:                }
0400:                dict.__setitem__("__rmul__",
0401:                        new PyMethodDescr("__rmul__", PyComplex.class, 1, 1,
0402:                                new exposed___rmul__(null, null)));
0403:                class exposed___rpow__ extends PyBuiltinMethodNarrow {
0404:
0405:                    exposed___rpow__(PyObject self, PyBuiltinFunction.Info info) {
0406:                        super (self, info);
0407:                    }
0408:
0409:                    public PyBuiltinFunction bind(PyObject self) {
0410:                        return new exposed___rpow__(self, info);
0411:                    }
0412:
0413:                    public PyObject __call__(PyObject arg0) {
0414:                        PyObject ret = ((PyComplex) self)
0415:                                .complex___rpow__(arg0);
0416:                        if (ret == null)
0417:                            return Py.NotImplemented;
0418:                        return ret;
0419:                    }
0420:
0421:                }
0422:                dict.__setitem__("__rpow__",
0423:                        new PyMethodDescr("__rpow__", PyComplex.class, 1, 1,
0424:                                new exposed___rpow__(null, null)));
0425:                class exposed___rsub__ extends PyBuiltinMethodNarrow {
0426:
0427:                    exposed___rsub__(PyObject self, PyBuiltinFunction.Info info) {
0428:                        super (self, info);
0429:                    }
0430:
0431:                    public PyBuiltinFunction bind(PyObject self) {
0432:                        return new exposed___rsub__(self, info);
0433:                    }
0434:
0435:                    public PyObject __call__(PyObject arg0) {
0436:                        PyObject ret = ((PyComplex) self)
0437:                                .complex___rsub__(arg0);
0438:                        if (ret == null)
0439:                            return Py.NotImplemented;
0440:                        return ret;
0441:                    }
0442:
0443:                }
0444:                dict.__setitem__("__rsub__",
0445:                        new PyMethodDescr("__rsub__", PyComplex.class, 1, 1,
0446:                                new exposed___rsub__(null, null)));
0447:                class exposed___rtruediv__ extends PyBuiltinMethodNarrow {
0448:
0449:                    exposed___rtruediv__(PyObject self,
0450:                            PyBuiltinFunction.Info info) {
0451:                        super (self, info);
0452:                    }
0453:
0454:                    public PyBuiltinFunction bind(PyObject self) {
0455:                        return new exposed___rtruediv__(self, info);
0456:                    }
0457:
0458:                    public PyObject __call__(PyObject arg0) {
0459:                        PyObject ret = ((PyComplex) self)
0460:                                .complex___rtruediv__(arg0);
0461:                        if (ret == null)
0462:                            return Py.NotImplemented;
0463:                        return ret;
0464:                    }
0465:
0466:                }
0467:                dict.__setitem__("__rtruediv__", new PyMethodDescr(
0468:                        "__rtruediv__", PyComplex.class, 1, 1,
0469:                        new exposed___rtruediv__(null, null)));
0470:                class exposed___sub__ extends PyBuiltinMethodNarrow {
0471:
0472:                    exposed___sub__(PyObject self, PyBuiltinFunction.Info info) {
0473:                        super (self, info);
0474:                    }
0475:
0476:                    public PyBuiltinFunction bind(PyObject self) {
0477:                        return new exposed___sub__(self, info);
0478:                    }
0479:
0480:                    public PyObject __call__(PyObject arg0) {
0481:                        PyObject ret = ((PyComplex) self).complex___sub__(arg0);
0482:                        if (ret == null)
0483:                            return Py.NotImplemented;
0484:                        return ret;
0485:                    }
0486:
0487:                }
0488:                dict
0489:                        .__setitem__("__sub__", new PyMethodDescr("__sub__",
0490:                                PyComplex.class, 1, 1, new exposed___sub__(
0491:                                        null, null)));
0492:                class exposed___truediv__ extends PyBuiltinMethodNarrow {
0493:
0494:                    exposed___truediv__(PyObject self,
0495:                            PyBuiltinFunction.Info info) {
0496:                        super (self, info);
0497:                    }
0498:
0499:                    public PyBuiltinFunction bind(PyObject self) {
0500:                        return new exposed___truediv__(self, info);
0501:                    }
0502:
0503:                    public PyObject __call__(PyObject arg0) {
0504:                        PyObject ret = ((PyComplex) self)
0505:                                .complex___truediv__(arg0);
0506:                        if (ret == null)
0507:                            return Py.NotImplemented;
0508:                        return ret;
0509:                    }
0510:
0511:                }
0512:                dict.__setitem__("__truediv__", new PyMethodDescr(
0513:                        "__truediv__", PyComplex.class, 1, 1,
0514:                        new exposed___truediv__(null, null)));
0515:                class exposed___eq__ extends PyBuiltinMethodNarrow {
0516:
0517:                    exposed___eq__(PyObject self, PyBuiltinFunction.Info info) {
0518:                        super (self, info);
0519:                    }
0520:
0521:                    public PyBuiltinFunction bind(PyObject self) {
0522:                        return new exposed___eq__(self, info);
0523:                    }
0524:
0525:                    public PyObject __call__(PyObject arg0) {
0526:                        PyObject ret = ((PyComplex) self).complex___eq__(arg0);
0527:                        if (ret == null)
0528:                            return Py.NotImplemented;
0529:                        return ret;
0530:                    }
0531:
0532:                }
0533:                dict.__setitem__("__eq__", new PyMethodDescr("__eq__",
0534:                        PyComplex.class, 1, 1, new exposed___eq__(null, null)));
0535:                class exposed___ne__ extends PyBuiltinMethodNarrow {
0536:
0537:                    exposed___ne__(PyObject self, PyBuiltinFunction.Info info) {
0538:                        super (self, info);
0539:                    }
0540:
0541:                    public PyBuiltinFunction bind(PyObject self) {
0542:                        return new exposed___ne__(self, info);
0543:                    }
0544:
0545:                    public PyObject __call__(PyObject arg0) {
0546:                        PyObject ret = ((PyComplex) self).complex___ne__(arg0);
0547:                        if (ret == null)
0548:                            return Py.NotImplemented;
0549:                        return ret;
0550:                    }
0551:
0552:                }
0553:                dict.__setitem__("__ne__", new PyMethodDescr("__ne__",
0554:                        PyComplex.class, 1, 1, new exposed___ne__(null, null)));
0555:                class exposed___ge__ extends PyBuiltinMethodNarrow {
0556:
0557:                    exposed___ge__(PyObject self, PyBuiltinFunction.Info info) {
0558:                        super (self, info);
0559:                    }
0560:
0561:                    public PyBuiltinFunction bind(PyObject self) {
0562:                        return new exposed___ge__(self, info);
0563:                    }
0564:
0565:                    public PyObject __call__(PyObject arg0) {
0566:                        PyObject ret = ((PyComplex) self).complex___ge__(arg0);
0567:                        if (ret == null)
0568:                            return Py.NotImplemented;
0569:                        return ret;
0570:                    }
0571:
0572:                }
0573:                dict.__setitem__("__ge__", new PyMethodDescr("__ge__",
0574:                        PyComplex.class, 1, 1, new exposed___ge__(null, null)));
0575:                class exposed___le__ extends PyBuiltinMethodNarrow {
0576:
0577:                    exposed___le__(PyObject self, PyBuiltinFunction.Info info) {
0578:                        super (self, info);
0579:                    }
0580:
0581:                    public PyBuiltinFunction bind(PyObject self) {
0582:                        return new exposed___le__(self, info);
0583:                    }
0584:
0585:                    public PyObject __call__(PyObject arg0) {
0586:                        PyObject ret = ((PyComplex) self).complex___le__(arg0);
0587:                        if (ret == null)
0588:                            return Py.NotImplemented;
0589:                        return ret;
0590:                    }
0591:
0592:                }
0593:                dict.__setitem__("__le__", new PyMethodDescr("__le__",
0594:                        PyComplex.class, 1, 1, new exposed___le__(null, null)));
0595:                class exposed___gt__ extends PyBuiltinMethodNarrow {
0596:
0597:                    exposed___gt__(PyObject self, PyBuiltinFunction.Info info) {
0598:                        super (self, info);
0599:                    }
0600:
0601:                    public PyBuiltinFunction bind(PyObject self) {
0602:                        return new exposed___gt__(self, info);
0603:                    }
0604:
0605:                    public PyObject __call__(PyObject arg0) {
0606:                        PyObject ret = ((PyComplex) self).complex___gt__(arg0);
0607:                        if (ret == null)
0608:                            return Py.NotImplemented;
0609:                        return ret;
0610:                    }
0611:
0612:                }
0613:                dict.__setitem__("__gt__", new PyMethodDescr("__gt__",
0614:                        PyComplex.class, 1, 1, new exposed___gt__(null, null)));
0615:                class exposed___lt__ extends PyBuiltinMethodNarrow {
0616:
0617:                    exposed___lt__(PyObject self, PyBuiltinFunction.Info info) {
0618:                        super (self, info);
0619:                    }
0620:
0621:                    public PyBuiltinFunction bind(PyObject self) {
0622:                        return new exposed___lt__(self, info);
0623:                    }
0624:
0625:                    public PyObject __call__(PyObject arg0) {
0626:                        PyObject ret = ((PyComplex) self).complex___lt__(arg0);
0627:                        if (ret == null)
0628:                            return Py.NotImplemented;
0629:                        return ret;
0630:                    }
0631:
0632:                }
0633:                dict.__setitem__("__lt__", new PyMethodDescr("__lt__",
0634:                        PyComplex.class, 1, 1, new exposed___lt__(null, null)));
0635:                class exposed___pow__ extends PyBuiltinMethodNarrow {
0636:
0637:                    exposed___pow__(PyObject self, PyBuiltinFunction.Info info) {
0638:                        super (self, info);
0639:                    }
0640:
0641:                    public PyBuiltinFunction bind(PyObject self) {
0642:                        return new exposed___pow__(self, info);
0643:                    }
0644:
0645:                    public PyObject __call__(PyObject arg0, PyObject arg1) {
0646:                        PyObject ret = ((PyComplex) self).complex___pow__(arg0,
0647:                                arg1);
0648:                        if (ret == null)
0649:                            return Py.NotImplemented;
0650:                        return ret;
0651:                    }
0652:
0653:                    public PyObject __call__(PyObject arg0) {
0654:                        PyObject ret = ((PyComplex) self).complex___pow__(arg0,
0655:                                null);
0656:                        if (ret == null)
0657:                            return Py.NotImplemented;
0658:                        return ret;
0659:                    }
0660:
0661:                }
0662:                dict
0663:                        .__setitem__("__pow__", new PyMethodDescr("__pow__",
0664:                                PyComplex.class, 1, 2, new exposed___pow__(
0665:                                        null, null)));
0666:                class exposed_conjugate extends PyBuiltinMethodNarrow {
0667:
0668:                    exposed_conjugate(PyObject self, PyBuiltinFunction.Info info) {
0669:                        super (self, info);
0670:                    }
0671:
0672:                    public PyBuiltinFunction bind(PyObject self) {
0673:                        return new exposed_conjugate(self, info);
0674:                    }
0675:
0676:                    public PyObject __call__() {
0677:                        return ((PyComplex) self).complex_conjugate();
0678:                    }
0679:
0680:                }
0681:                dict.__setitem__("conjugate", new PyMethodDescr("conjugate",
0682:                        PyComplex.class, 0, 0,
0683:                        new exposed_conjugate(null, null)));
0684:                class exposed___nonzero__ extends PyBuiltinMethodNarrow {
0685:
0686:                    exposed___nonzero__(PyObject self,
0687:                            PyBuiltinFunction.Info info) {
0688:                        super (self, info);
0689:                    }
0690:
0691:                    public PyBuiltinFunction bind(PyObject self) {
0692:                        return new exposed___nonzero__(self, info);
0693:                    }
0694:
0695:                    public PyObject __call__() {
0696:                        return Py.newBoolean(((PyComplex) self)
0697:                                .complex___nonzero__());
0698:                    }
0699:
0700:                }
0701:                dict.__setitem__("__nonzero__", new PyMethodDescr(
0702:                        "__nonzero__", PyComplex.class, 0, 0,
0703:                        new exposed___nonzero__(null, null)));
0704:                class exposed___reduce__ extends PyBuiltinMethodNarrow {
0705:
0706:                    exposed___reduce__(PyObject self,
0707:                            PyBuiltinFunction.Info info) {
0708:                        super (self, info);
0709:                    }
0710:
0711:                    public PyBuiltinFunction bind(PyObject self) {
0712:                        return new exposed___reduce__(self, info);
0713:                    }
0714:
0715:                    public PyObject __call__() {
0716:                        return ((PyComplex) self).complex___reduce__();
0717:                    }
0718:
0719:                }
0720:                dict.__setitem__("__reduce__", new PyMethodDescr("__reduce__",
0721:                        PyComplex.class, 0, 0, new exposed___reduce__(null,
0722:                                null)));
0723:                class exposed___repr__ extends PyBuiltinMethodNarrow {
0724:
0725:                    exposed___repr__(PyObject self, PyBuiltinFunction.Info info) {
0726:                        super (self, info);
0727:                    }
0728:
0729:                    public PyBuiltinFunction bind(PyObject self) {
0730:                        return new exposed___repr__(self, info);
0731:                    }
0732:
0733:                    public PyObject __call__() {
0734:                        return new PyString(((PyComplex) self)
0735:                                .complex_toString());
0736:                    }
0737:
0738:                }
0739:                dict.__setitem__("__repr__",
0740:                        new PyMethodDescr("__repr__", PyComplex.class, 0, 0,
0741:                                new exposed___repr__(null, null)));
0742:                class exposed___str__ extends PyBuiltinMethodNarrow {
0743:
0744:                    exposed___str__(PyObject self, PyBuiltinFunction.Info info) {
0745:                        super (self, info);
0746:                    }
0747:
0748:                    public PyBuiltinFunction bind(PyObject self) {
0749:                        return new exposed___str__(self, info);
0750:                    }
0751:
0752:                    public PyObject __call__() {
0753:                        return new PyString(((PyComplex) self)
0754:                                .complex_toString());
0755:                    }
0756:
0757:                }
0758:                dict
0759:                        .__setitem__("__str__", new PyMethodDescr("__str__",
0760:                                PyComplex.class, 0, 0, new exposed___str__(
0761:                                        null, null)));
0762:                class exposed___hash__ extends PyBuiltinMethodNarrow {
0763:
0764:                    exposed___hash__(PyObject self, PyBuiltinFunction.Info info) {
0765:                        super (self, info);
0766:                    }
0767:
0768:                    public PyBuiltinFunction bind(PyObject self) {
0769:                        return new exposed___hash__(self, info);
0770:                    }
0771:
0772:                    public PyObject __call__() {
0773:                        return Py.newInteger(((PyComplex) self)
0774:                                .complex_hashCode());
0775:                    }
0776:
0777:                }
0778:                dict.__setitem__("__hash__",
0779:                        new PyMethodDescr("__hash__", PyComplex.class, 0, 0,
0780:                                new exposed___hash__(null, null)));
0781:                dict.__setitem__("__new__", new PyNewWrapper(PyComplex.class,
0782:                        "__new__", -1, -1) {
0783:
0784:                    public PyObject new_impl(boolean init, PyType subtype,
0785:                            PyObject[] args, String[] keywords) {
0786:                        return complex_new(this , init, subtype, args, keywords);
0787:                    }
0788:
0789:                });
0790:            }
0791:
0792:            //~ END GENERATED REGION -- DO NOT EDIT SEE gexpose.py
0793:
0794:            public static PyObject complex_new(PyNewWrapper new_, boolean init,
0795:                    PyType subtype, PyObject[] args, String[] keywords) {
0796:                if (args.length == 0) {
0797:                    if (new_.for_type == subtype) {
0798:                        return new PyComplex(0, 0);
0799:                    }
0800:                    return new PyComplexDerived(subtype, 0, 0);
0801:                }
0802:
0803:                if (args.length > 2)
0804:                    throw Py.TypeError("complex() "
0805:                            + "takes at most 2 arguments (" + args.length
0806:                            + " given)");
0807:
0808:                // optimize complex(int, int) here?
0809:
0810:                ArgParser ap = new ArgParser("complex", args, keywords, "real",
0811:                        "imag");
0812:                PyObject real = ap.getPyObject(0, Py.Zero);
0813:                PyObject imag = ap.getPyObject(1, null);
0814:
0815:                if (imag != null) {
0816:                    if (real instanceof  PyString)
0817:                        throw Py.TypeError("complex() "
0818:                                + "can't take second arg if first is a string");
0819:                    if (imag instanceof  PyString)
0820:                        throw Py.TypeError("complex() "
0821:                                + "second arg can't be a string");
0822:                }
0823:
0824:                PyComplex ret = null;
0825:                try {
0826:                    ret = real.__complex__();
0827:                } catch (PyException pye) {
0828:                    // i.e PyString.__complex__ throws ValueError
0829:                    if (!(Py.matchException(pye, Py.AttributeError)))
0830:                        throw pye;
0831:                }
0832:
0833:                try {
0834:                    if (ret == null)
0835:                        ret = new PyComplex(real.__float__().getValue(), 0);
0836:                    if (imag != null) {
0837:                        if (ret == real)
0838:                            ret = new PyComplex(ret.real, ret.imag);
0839:                        if (imag instanceof  PyComplex) {
0840:                            // optimize away __mul__()
0841:                            // IMO only allowed on pure PyComplex objects, but CPython
0842:                            // does it on all complex subtypes, so I do too.
0843:                            PyComplex c = (PyComplex) imag;
0844:                            ret.real -= c.imag;
0845:                            ret.imag += c.real;
0846:                        } else {
0847:                            // CPython doesn't call __complex__ on second argument
0848:                            ret.imag += imag.__float__().getValue();
0849:                        }
0850:                    }
0851:                    if (new_.for_type == subtype) {
0852:                        return ret;
0853:                    } else {
0854:                        return new PyComplexDerived(subtype, ret.real, ret.imag);
0855:                    }
0856:                } catch (PyException pye) {
0857:                    // convert all AttributeErrors except on PyInstance to TypeError
0858:                    if (Py.matchException(pye, Py.AttributeError)) {
0859:                        Object o = (ret == null ? real : imag);
0860:                        if (!(o instanceof  PyInstance))
0861:                            throw Py.TypeError("complex() "
0862:                                    + "argument must be a string or a number");
0863:                    }
0864:                    throw pye;
0865:                }
0866:            }
0867:
0868:            private static final PyType COMPLEXTYPE = PyType
0869:                    .fromClass(PyComplex.class);
0870:
0871:            public PyComplex(PyType subtype, double r, double i) {
0872:                super (subtype);
0873:                real = r;
0874:                imag = i;
0875:            }
0876:
0877:            public PyComplex(double r, double i) {
0878:                this (COMPLEXTYPE, r, i);
0879:            }
0880:
0881:            public String safeRepr() throws PyIgnoreMethodTag {
0882:                return "'complex' object";
0883:            }
0884:
0885:            public final PyFloat getReal() {
0886:                return Py.newFloat(real);
0887:            }
0888:
0889:            public final PyFloat getImag() {
0890:                return Py.newFloat(imag);
0891:            }
0892:
0893:            public static String toString(double value) {
0894:                if (value == Math.floor(value) && value <= Long.MAX_VALUE
0895:                        && value >= Long.MIN_VALUE) {
0896:                    return Long.toString((long) value);
0897:                } else {
0898:                    return Double.toString(value);
0899:                }
0900:            }
0901:
0902:            public String toString() {
0903:                return complex_toString();
0904:            }
0905:
0906:            final String complex_toString() {
0907:                if (real == 0.) {
0908:                    return toString(imag) + "j";
0909:                } else {
0910:                    if (imag >= 0) {
0911:                        return "(" + toString(real) + "+" + toString(imag)
0912:                                + "j)";
0913:                    } else {
0914:                        return "(" + toString(real) + "-" + toString(-imag)
0915:                                + "j)";
0916:                    }
0917:                }
0918:            }
0919:
0920:            public int hashCode() {
0921:                return complex_hashCode();
0922:            }
0923:
0924:            final int complex_hashCode() {
0925:                if (imag == 0) {
0926:                    return new PyFloat(real).hashCode();
0927:                } else {
0928:                    long v = Double.doubleToLongBits(real)
0929:                            ^ Double.doubleToLongBits(imag);
0930:                    return (int) v ^ (int) (v >> 32);
0931:                }
0932:            }
0933:
0934:            public boolean __nonzero__() {
0935:                return complex___nonzero__();
0936:            }
0937:
0938:            final boolean complex___nonzero__() {
0939:                return real != 0 && imag != 0;
0940:            }
0941:
0942:            /*public Object __tojava__(Class c) {
0943:              return super.__tojava__(c);
0944:              }*/
0945:
0946:            public int __cmp__(PyObject other) {
0947:                return complex___cmp__(other);
0948:            }
0949:
0950:            final int complex___cmp__(PyObject other) {
0951:                if (!canCoerce(other))
0952:                    return -2;
0953:                PyComplex c = coerce(other);
0954:                double oreal = c.real;
0955:                double oimag = c.imag;
0956:                if (real == oreal && imag == oimag)
0957:                    return 0;
0958:                if (real != oreal) {
0959:                    return real < oreal ? -1 : 1;
0960:                } else {
0961:                    return imag < oimag ? -1 : 1;
0962:                }
0963:            }
0964:
0965:            /*
0966:             * @see org.python.core.PyObject#__eq__(org.python.core.PyObject)
0967:             */
0968:            public PyObject __eq__(PyObject other) {
0969:                return complex___eq__(other);
0970:            }
0971:
0972:            final PyObject complex___eq__(PyObject other) {
0973:                if (!canCoerce(other))
0974:                    return null;
0975:                PyComplex c = coerce(other);
0976:                return Py.newBoolean(real == c.real && imag == c.imag);
0977:            }
0978:
0979:            /*
0980:             * @see org.python.core.PyObject#__ne__(org.python.core.PyObject)
0981:             */
0982:            public PyObject __ne__(PyObject other) {
0983:                return complex___ne__(other);
0984:            }
0985:
0986:            final PyObject complex___ne__(PyObject other) {
0987:                if (!canCoerce(other))
0988:                    return null;
0989:                PyComplex c = coerce(other);
0990:                return Py.newBoolean(real != c.real || imag != c.imag);
0991:            }
0992:
0993:            private PyObject unsupported_comparison(PyObject other) {
0994:                if (!canCoerce(other))
0995:                    return null;
0996:                throw Py
0997:                        .TypeError("cannot compare complex numbers using <, <=, >, >=");
0998:            }
0999:
1000:            public PyObject __ge__(PyObject other) {
1001:                return complex___ge__(other);
1002:            }
1003:
1004:            final PyObject complex___ge__(PyObject other) {
1005:                return unsupported_comparison(other);
1006:            }
1007:
1008:            public PyObject __gt__(PyObject other) {
1009:                return complex___gt__(other);
1010:            }
1011:
1012:            final PyObject complex___gt__(PyObject other) {
1013:                return unsupported_comparison(other);
1014:            }
1015:
1016:            public PyObject __le__(PyObject other) {
1017:                return complex___le__(other);
1018:            }
1019:
1020:            final PyObject complex___le__(PyObject other) {
1021:                return unsupported_comparison(other);
1022:            }
1023:
1024:            public PyObject __lt__(PyObject other) {
1025:                return complex___lt__(other);
1026:            }
1027:
1028:            final PyObject complex___lt__(PyObject other) {
1029:                return unsupported_comparison(other);
1030:            }
1031:
1032:            public Object __coerce_ex__(PyObject other) {
1033:                if (other instanceof  PyComplex)
1034:                    return other;
1035:                if (other instanceof  PyFloat)
1036:                    return new PyComplex(((PyFloat) other).getValue(), 0);
1037:                if (other instanceof  PyInteger)
1038:                    return new PyComplex((double) ((PyInteger) other)
1039:                            .getValue(), 0);
1040:                if (other instanceof  PyLong)
1041:                    return new PyComplex(((PyLong) other).doubleValue(), 0);
1042:                return Py.None;
1043:            }
1044:
1045:            private final boolean canCoerce(PyObject other) {
1046:                return other instanceof  PyComplex || other instanceof  PyFloat
1047:                        || other instanceof  PyInteger
1048:                        || other instanceof  PyLong;
1049:            }
1050:
1051:            private final PyComplex coerce(PyObject other) {
1052:                if (other instanceof  PyComplex)
1053:                    return (PyComplex) other;
1054:                if (other instanceof  PyFloat)
1055:                    return new PyComplex(((PyFloat) other).getValue(), 0);
1056:                if (other instanceof  PyInteger)
1057:                    return new PyComplex((double) ((PyInteger) other)
1058:                            .getValue(), 0);
1059:                if (other instanceof  PyLong)
1060:                    return new PyComplex(((PyLong) other).doubleValue(), 0);
1061:                throw Py.TypeError("xxx");
1062:            }
1063:
1064:            public PyObject __add__(PyObject right) {
1065:                return complex___add__(right);
1066:            }
1067:
1068:            final PyObject complex___add__(PyObject right) {
1069:                if (!canCoerce(right))
1070:                    return null;
1071:                PyComplex c = coerce(right);
1072:                return new PyComplex(real + c.real, imag + c.imag);
1073:            }
1074:
1075:            public PyObject __radd__(PyObject left) {
1076:                return complex___radd__(left);
1077:            }
1078:
1079:            final PyObject complex___radd__(PyObject left) {
1080:                return __add__(left);
1081:            }
1082:
1083:            private final static PyObject _sub(PyComplex o1, PyComplex o2) {
1084:                return new PyComplex(o1.real - o2.real, o1.imag - o2.imag);
1085:            }
1086:
1087:            public PyObject __sub__(PyObject right) {
1088:                return complex___sub__(right);
1089:            }
1090:
1091:            final PyObject complex___sub__(PyObject right) {
1092:                if (!canCoerce(right))
1093:                    return null;
1094:                return _sub(this , coerce(right));
1095:            }
1096:
1097:            public PyObject __rsub__(PyObject left) {
1098:                return complex___rsub__(left);
1099:            }
1100:
1101:            final PyObject complex___rsub__(PyObject left) {
1102:                if (!canCoerce(left))
1103:                    return null;
1104:                return _sub(coerce(left), this );
1105:            }
1106:
1107:            private final static PyObject _mul(PyComplex o1, PyComplex o2) {
1108:                return new PyComplex(o1.real * o2.real - o1.imag * o2.imag,
1109:                        o1.real * o2.imag + o1.imag * o2.real);
1110:            }
1111:
1112:            public PyObject __mul__(PyObject right) {
1113:                return complex___mul__(right);
1114:            }
1115:
1116:            final PyObject complex___mul__(PyObject right) {
1117:                if (!canCoerce(right))
1118:                    return null;
1119:                return _mul(this , coerce(right));
1120:            }
1121:
1122:            public PyObject __rmul__(PyObject left) {
1123:                return complex___rmul__(left);
1124:            }
1125:
1126:            final PyObject complex___rmul__(PyObject left) {
1127:                if (!canCoerce(left))
1128:                    return null;
1129:                return _mul(coerce(left), this );
1130:            }
1131:
1132:            private final static PyObject _div(PyComplex a, PyComplex b) {
1133:                double abs_breal = b.real < 0 ? -b.real : b.real;
1134:                double abs_bimag = b.imag < 0 ? -b.imag : b.imag;
1135:                if (abs_breal >= abs_bimag) {
1136:                    // Divide tops and bottom by b.real
1137:                    if (abs_breal == 0.0) {
1138:                        throw Py.ZeroDivisionError("complex division");
1139:                    }
1140:                    double ratio = b.imag / b.real;
1141:                    double denom = b.real + b.imag * ratio;
1142:                    return new PyComplex((a.real + a.imag * ratio) / denom,
1143:                            (a.imag - a.real * ratio) / denom);
1144:                } else {
1145:                    /* divide tops and bottom by b.imag */
1146:                    double ratio = b.real / b.imag;
1147:                    double denom = b.real * ratio + b.imag;
1148:                    return new PyComplex((a.real * ratio + a.imag) / denom,
1149:                            (a.imag * ratio - a.real) / denom);
1150:                }
1151:            }
1152:
1153:            public PyObject __div__(PyObject right) {
1154:                return complex___div__(right);
1155:            }
1156:
1157:            final PyObject complex___div__(PyObject right) {
1158:                if (!canCoerce(right))
1159:                    return null;
1160:                if (Options.divisionWarning >= 2)
1161:                    Py.warning(Py.DeprecationWarning,
1162:                            "classic complex division");
1163:                return _div(this , coerce(right));
1164:            }
1165:
1166:            public PyObject __rdiv__(PyObject left) {
1167:                return complex___rdiv__(left);
1168:            }
1169:
1170:            final PyObject complex___rdiv__(PyObject left) {
1171:                if (!canCoerce(left))
1172:                    return null;
1173:                if (Options.divisionWarning >= 2)
1174:                    Py.warning(Py.DeprecationWarning,
1175:                            "classic complex division");
1176:                return _div(coerce(left), this );
1177:            }
1178:
1179:            public PyObject __floordiv__(PyObject right) {
1180:                return complex___floordiv__(right);
1181:            }
1182:
1183:            final PyObject complex___floordiv__(PyObject right) {
1184:                if (!canCoerce(right))
1185:                    return null;
1186:                return _divmod(this , coerce(right)).__finditem__(0);
1187:            }
1188:
1189:            public PyObject __rfloordiv__(PyObject left) {
1190:                return complex___floordiv__(left);
1191:            }
1192:
1193:            final PyObject complex___rfloordiv__(PyObject left) {
1194:                if (!canCoerce(left))
1195:                    return null;
1196:                return _divmod(coerce(left), this ).__finditem__(0);
1197:            }
1198:
1199:            public PyObject __truediv__(PyObject right) {
1200:                return complex___truediv__(right);
1201:            }
1202:
1203:            final PyObject complex___truediv__(PyObject right) {
1204:                if (!canCoerce(right))
1205:                    return null;
1206:                return _div(this , coerce(right));
1207:            }
1208:
1209:            public PyObject __rtruediv__(PyObject left) {
1210:                return complex___rtruediv__(left);
1211:            }
1212:
1213:            final PyObject complex___rtruediv__(PyObject left) {
1214:                if (!canCoerce(left))
1215:                    return null;
1216:                return _div(coerce(left), this );
1217:            }
1218:
1219:            public PyObject __mod__(PyObject right) {
1220:                return complex___mod__(right);
1221:            }
1222:
1223:            final PyObject complex___mod__(PyObject right) {
1224:                if (!canCoerce(right))
1225:                    return null;
1226:                return _mod(this , coerce(right));
1227:            }
1228:
1229:            public PyObject __rmod__(PyObject left) {
1230:                return complex___rmod__(left);
1231:            }
1232:
1233:            final PyObject complex___rmod__(PyObject left) {
1234:                if (!canCoerce(left))
1235:                    return null;
1236:                return _mod(coerce(left), this );
1237:            }
1238:
1239:            private static PyObject _mod(PyComplex value, PyComplex right) {
1240:                PyComplex z = (PyComplex) _div(value, right);
1241:
1242:                z.real = Math.floor(z.real);
1243:                z.imag = 0.0;
1244:
1245:                return value.__sub__(z.__mul__(right));
1246:            }
1247:
1248:            public PyObject __divmod__(PyObject right) {
1249:                return complex___divmod__(right);
1250:            }
1251:
1252:            final PyObject complex___divmod__(PyObject right) {
1253:                if (!canCoerce(right))
1254:                    return null;
1255:                return _divmod(this , coerce(right));
1256:            }
1257:
1258:            public PyObject __rdivmod__(PyObject left) {
1259:                return complex___rdivmod__(left);
1260:            }
1261:
1262:            final PyObject complex___rdivmod__(PyObject left) {
1263:                if (!canCoerce(left))
1264:                    return null;
1265:                return _divmod(coerce(left), this );
1266:            }
1267:
1268:            private static PyObject _divmod(PyComplex value, PyComplex right) {
1269:                PyComplex z = (PyComplex) _div(value, right);
1270:
1271:                z.real = Math.floor(z.real);
1272:                z.imag = 0.0;
1273:
1274:                return new PyTuple(new PyObject[] { z,
1275:                        value.__sub__(z.__mul__(right)) });
1276:            }
1277:
1278:            private static PyObject ipow(PyComplex value, int iexp) {
1279:                int pow = iexp;
1280:                if (pow < 0)
1281:                    pow = -pow;
1282:
1283:                double xr = value.real;
1284:                double xi = value.imag;
1285:
1286:                double zr = 1;
1287:                double zi = 0;
1288:
1289:                double tmp;
1290:
1291:                while (pow > 0) {
1292:                    if ((pow & 0x1) != 0) {
1293:                        tmp = zr * xr - zi * xi;
1294:                        zi = zi * xr + zr * xi;
1295:                        zr = tmp;
1296:                    }
1297:                    pow >>= 1;
1298:                    if (pow == 0)
1299:                        break;
1300:                    tmp = xr * xr - xi * xi;
1301:                    xi = xr * xi * 2;
1302:                    xr = tmp;
1303:                }
1304:
1305:                PyComplex ret = new PyComplex(zr, zi);
1306:
1307:                if (iexp < 0)
1308:                    return new PyComplex(1, 0).__div__(ret);
1309:                return ret;
1310:            }
1311:
1312:            public PyObject __pow__(PyObject right, PyObject modulo) {
1313:                return complex___pow__(right, modulo);
1314:            }
1315:
1316:            final PyObject complex___pow__(PyObject right, PyObject modulo) {
1317:                if (modulo != null) {
1318:                    throw Py.ValueError("complex modulo");
1319:                }
1320:                if (!canCoerce(right))
1321:                    return null;
1322:                return _pow(this , coerce(right));
1323:            }
1324:
1325:            public PyObject __rpow__(PyObject left) {
1326:                return complex___rpow__(left);
1327:            }
1328:
1329:            final PyObject complex___rpow__(PyObject left) {
1330:                if (!canCoerce(left))
1331:                    return null;
1332:                return _pow(coerce(left), this );
1333:            }
1334:
1335:            public static PyObject _pow(PyComplex value, PyComplex right) {
1336:                double xr = value.real;
1337:                double xi = value.imag;
1338:                double yr = right.real;
1339:                double yi = right.imag;
1340:
1341:                if (yr == 0 && yi == 0) {
1342:                    return new PyComplex(1, 0);
1343:                }
1344:
1345:                if (xr == 0 && xi == 0) {
1346:                    if (yi != 0 || yr < 0) {
1347:                        throw Py
1348:                                .ValueError("0.0 to a negative or complex power");
1349:                    }
1350:                }
1351:
1352:                // Check for integral powers
1353:                int iexp = (int) yr;
1354:                if (yi == 0 && yr == (double) iexp && iexp >= -128
1355:                        && iexp <= 128) {
1356:                    return ipow(value, iexp);
1357:                }
1358:
1359:                double abs = ExtraMath.hypot(xr, xi);
1360:                double len = Math.pow(abs, yr);
1361:
1362:                double at = Math.atan2(xi, xr);
1363:                double phase = at * yr;
1364:                if (yi != 0) {
1365:                    len /= Math.exp(at * yi);
1366:                    phase += yi * Math.log(abs);
1367:                }
1368:                return new PyComplex(len * Math.cos(phase), len
1369:                        * Math.sin(phase));
1370:            }
1371:
1372:            public PyObject __neg__() {
1373:                return complex___neg__();
1374:            }
1375:
1376:            final PyObject complex___neg__() {
1377:                return new PyComplex(-real, -imag);
1378:            }
1379:
1380:            public PyObject __pos__() {
1381:                return complex___pos__();
1382:            }
1383:
1384:            final PyObject complex___pos__() {
1385:                return new PyComplex(real, imag);
1386:            }
1387:
1388:            public PyObject __invert__() {
1389:                throw Py.TypeError("bad operand type for unary ~");
1390:            }
1391:
1392:            public PyObject __abs__() {
1393:                return complex___abs__();
1394:            }
1395:
1396:            final PyObject complex___abs__() {
1397:                return new PyFloat(ExtraMath.hypot(real, imag));
1398:            }
1399:
1400:            public PyObject __int__() {
1401:                return complex___int__();
1402:            }
1403:
1404:            final PyInteger complex___int__() {
1405:                throw Py
1406:                        .TypeError("can't convert complex to int; use e.g. int(abs(z))");
1407:            }
1408:
1409:            public PyLong __long__() {
1410:                return complex___long__();
1411:            }
1412:
1413:            final PyLong complex___long__() {
1414:                throw Py
1415:                        .TypeError("can't convert complex to long; use e.g. long(abs(z))");
1416:            }
1417:
1418:            public PyFloat __float__() {
1419:                return complex___float__();
1420:            }
1421:
1422:            final PyFloat complex___float__() {
1423:                throw Py
1424:                        .TypeError("can't convert complex to float; use e.g. abs(z)");
1425:            }
1426:
1427:            public PyComplex __complex__() {
1428:                return new PyComplex(real, imag);
1429:            }
1430:
1431:            public PyComplex conjugate() {
1432:                return complex_conjugate();
1433:            }
1434:
1435:            final PyComplex complex_conjugate() {
1436:                return new PyComplex(real, -imag);
1437:            }
1438:
1439:            /**
1440:             * Used for pickling.
1441:             *
1442:             * @return a tuple of (class, (Integer))
1443:             */
1444:            public PyObject __reduce__() {
1445:                return complex___reduce__();
1446:            }
1447:
1448:            final PyObject complex___reduce__() {
1449:                return new PyTuple(new PyObject[] { getType(),
1450:                        new PyTuple(new PyObject[] { getReal(), getImag() }) });
1451:            }
1452:
1453:            public boolean isMappingType() {
1454:                return false;
1455:            }
1456:
1457:            public boolean isSequenceType() {
1458:                return false;
1459:            }
1460:        }
www.java2java.com | Contact Us
Copyright 2009 - 12 Demo Source and Support. All rights reserved.
All other trademarks are property of their respective owners.