mirror of
https://github.com/ml-explore/mlx.git
synced 2025-12-16 01:49:05 +08:00
14
mlx/ops.cpp
14
mlx/ops.cpp
@@ -4657,4 +4657,18 @@ array roll(
|
||||
return roll(a, std::vector<int>{total_shift}, std::vector<int>{axis}, s);
|
||||
}
|
||||
|
||||
array real(const array& a, StreamOrDevice s /* = {} */) {
|
||||
if (!issubdtype(a.dtype(), complexfloating)) {
|
||||
return a;
|
||||
}
|
||||
return array(a.shape(), float32, std::make_shared<Real>(to_stream(s)), {a});
|
||||
}
|
||||
|
||||
array imag(const array& a, StreamOrDevice s /* = {} */) {
|
||||
if (!issubdtype(a.dtype(), complexfloating)) {
|
||||
return zeros_like(a);
|
||||
}
|
||||
return array(a.shape(), float32, std::make_shared<Imag>(to_stream(s)), {a});
|
||||
}
|
||||
|
||||
} // namespace mlx::core
|
||||
|
||||
Reference in New Issue
Block a user