Add the bartlett function (#3155)

This commit is contained in:
willem adnet
2026-03-03 20:40:54 +01:00
committed by GitHub
parent f145ece976
commit 8cd377b7db
4 changed files with 52 additions and 0 deletions
+22
View File
@@ -1428,6 +1428,28 @@ void init_ops(nb::module_& m) {
"stream"_a = nb::none(),
nb::sig(
"def arange(stop : Union[int, float], step : Union[None, int, float] = None, dtype: Optional[Dtype] = None, *, stream: Union[None, Stream, Device] = None) -> array"));
m.def(
"bartlett",
&mlx::core::bartlett,
"M"_a,
nb::kw_only(),
"stream"_a = nb::none(),
R"pbdoc(
Return the Bartlett window.
The Bartlett window is a taper formed by using a weighted cosine.
.. math::
w(n) = 1 - \frac{2|n - (M-1)/2|}{M-1}
\qquad 0 \le n \le M-1
Args:
M (int): Number of points in the output window.
Returns:
array: The window, with the maximum value normalized to one (the value one
appears only if the number of samples is odd).
)pbdoc");
m.def(
"hanning",
&mlx::core::hanning,