Skip to content

Commit 07c2fce

Browse files
committed
Adding conjugate function.
1 parent 2046f81 commit 07c2fce

File tree

2 files changed

+10
-0
lines changed

2 files changed

+10
-0
lines changed

graalpython/com.oracle.graal.python.test/src/tests/unittest_tags/test_complex.txt

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
*ComplexTest.test_abs
22
*ComplexTest.test_boolcontext
3+
*ComplexTest.test_conjugate
34
*ComplexTest.test_divmod
45
*ComplexTest.test_file
56
*ComplexTest.test_getnewargs

graalpython/com.oracle.graal.python/src/com/oracle/graal/python/builtins/objects/complex/ComplexBuiltins.java

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -632,4 +632,13 @@ int hash(PComplex self) {
632632
return realHash + PComplex.IMAG_MULTIPLIER * imagHash;
633633
}
634634
}
635+
636+
@GenerateNodeFactory
637+
@Builtin(name = "conjugate", minNumOfPositionalArgs = 1)
638+
abstract static class ConjugateNode extends PythonUnaryBuiltinNode {
639+
@Specialization
640+
PComplex hash(PComplex self) {
641+
return factory().createComplex(self.getReal(), -self.getImag());
642+
}
643+
}
635644
}

0 commit comments

Comments
 (0)