mirror of
https://github.com/ml-explore/mlx.git
synced 2025-09-18 18:28:12 +08:00
Adds radians and degrees (#1011)
This commit is contained in:
10
mlx/ops.cpp
10
mlx/ops.cpp
@@ -2192,6 +2192,16 @@ array arctanh(const array& a, StreamOrDevice s /* = {} */) {
|
||||
a.shape(), dtype, std::make_shared<ArcTanh>(to_stream(s)), {input});
|
||||
}
|
||||
|
||||
array degrees(const array& a, StreamOrDevice s /* = {} */) {
|
||||
auto dtype = at_least_float(a.dtype());
|
||||
return multiply(a, array(180.0 / M_PI, dtype), s);
|
||||
}
|
||||
|
||||
array radians(const array& a, StreamOrDevice s /* = {} */) {
|
||||
auto dtype = at_least_float(a.dtype());
|
||||
return multiply(a, array(M_PI / 180.0, dtype), s);
|
||||
}
|
||||
|
||||
array log(const array& a, StreamOrDevice s /* = {} */) {
|
||||
auto dtype = at_least_float(a.dtype());
|
||||
auto input = astype(a, dtype, s);
|
||||
|
@@ -851,6 +851,12 @@ array arccosh(const array& a, StreamOrDevice s = {});
|
||||
/** Inverse Hyperbolic Tangent of the elements of an array */
|
||||
array arctanh(const array& a, StreamOrDevice s = {});
|
||||
|
||||
/** Convert the elements of an array from Radians to Degrees **/
|
||||
array degrees(const array& a, StreamOrDevice s = {});
|
||||
|
||||
/** Convert the elements of an array from Degrees to Radians **/
|
||||
array radians(const array& a, StreamOrDevice s = {});
|
||||
|
||||
/** Natural logarithm of the elements of an array. */
|
||||
array log(const array& a, StreamOrDevice s = {});
|
||||
|
||||
|
Reference in New Issue
Block a user