mirror of
https://github.com/apple/pkl.git
synced 2026-04-18 06:29:45 +02:00
Add math.atan2 (#819)
This commit is contained in:
@@ -299,6 +299,28 @@ public final class MathNodes {
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class atan2 extends ExternalMethod2Node {
|
||||
@Specialization
|
||||
protected double eval(VmTyped self, long x, long y) {
|
||||
return StrictMath.atan2(x, y);
|
||||
}
|
||||
|
||||
@Specialization
|
||||
protected double eval(VmTyped self, long x, double y) {
|
||||
return StrictMath.atan2(x, y);
|
||||
}
|
||||
|
||||
@Specialization
|
||||
protected double eval(VmTyped self, double x, double y) {
|
||||
return StrictMath.atan2(x, y);
|
||||
}
|
||||
|
||||
@Specialization
|
||||
protected double eval(VmTyped self, double x, long y) {
|
||||
return StrictMath.atan2(x, y);
|
||||
}
|
||||
}
|
||||
|
||||
public abstract static class gcd extends ExternalMethod2Node {
|
||||
@TruffleBoundary
|
||||
@Specialization
|
||||
|
||||
@@ -130,6 +130,13 @@ examples {
|
||||
math.atan(math.tan(-2.34))
|
||||
}
|
||||
|
||||
["atan2"] {
|
||||
math.atan2(4, -3)
|
||||
math.atan2(4.5, -3.5)
|
||||
math.atan2(4.5, -3)
|
||||
math.atan2(4, 3.5)
|
||||
}
|
||||
|
||||
["gcd"] {
|
||||
math.gcd(0, 0)
|
||||
math.gcd(4, 6)
|
||||
@@ -189,3 +196,10 @@ examples {
|
||||
math.min(Infinity, -Infinity)
|
||||
}
|
||||
}
|
||||
|
||||
facts {
|
||||
["atan2"] {
|
||||
math.atan2(1, 0) == math.pi / 2
|
||||
math.atan2(0, -1) == math.pi
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,3 +1,9 @@
|
||||
facts {
|
||||
["atan2"] {
|
||||
true
|
||||
true
|
||||
}
|
||||
}
|
||||
examples {
|
||||
["minInt"] {
|
||||
-9223372036854775808
|
||||
@@ -109,6 +115,12 @@ examples {
|
||||
1.1415926535897931
|
||||
0.8015926535897934
|
||||
}
|
||||
["atan2"] {
|
||||
2.214297435588181
|
||||
2.2318394956455836
|
||||
2.1587989303424644
|
||||
0.851966327173272
|
||||
}
|
||||
["gcd"] {
|
||||
0
|
||||
2
|
||||
|
||||
Reference in New Issue
Block a user