add atan2 broadcast function
@@ -701,9 +701,22 @@ public class JVMDoubleTensor extends DoubleTensor {
return new JVMDoubleTensor(newBuffer, shapeCopy());
}
+ @Override
+ public DoubleTensor atan2InPlace(double y) {
+ for (int i = 0; i < buffer.length; i++) {
+ buffer[i] = FastMath.atan2(y, buffer[i]);
+ }
+ return this;
+ }
+
+ @Override
+ public DoubleTensor atan2InPlace(DoubleTensor y) {
+ return broadcastableOpInPlace((left, right) -> FastMath.atan2(right, left), y);
+ }
+
@Override
public DoubleTensor atan2(DoubleTensor y) {
- throw new NotImplementedException("");
+ return broadcastableOp((left, right) -> FastMath.atan2(right, left), y);
}
@Override
@@ -1070,27 +1083,6 @@ public class JVMDoubleTensor extends DoubleTensor {
return this;
}
- @Override
- public DoubleTensor atan2InPlace(double y) {
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = FastMath.atan2(y, buffer[i]);
- }
- return this;
- }
-
- @Override
- public DoubleTensor atan2InPlace(DoubleTensor y) {
- checkElementwiseShapeMatch(y.getShape());
-
- double[] thatBuffer = y.asFlatDoubleArray();
-
- for (int i = 0; i < buffer.length; i++) {
- buffer[i] = FastMath.atan2(thatBuffer[i], buffer[i]);
- }
-
- return this;
- }
-
@Override
public DoubleTensor asinInPlace() {
for (int i = 0; i < buffer.length; i++) {
