xbarray 0.0.1a13__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (51) hide show
  1. array_api_typing/__init__.py +9 -0
  2. array_api_typing/typing_2024_12/__init__.py +12 -0
  3. array_api_typing/typing_2024_12/_api_constant.py +32 -0
  4. array_api_typing/typing_2024_12/_api_fft_typing.py +717 -0
  5. array_api_typing/typing_2024_12/_api_linalg_typing.py +897 -0
  6. array_api_typing/typing_2024_12/_api_return_typing.py +103 -0
  7. array_api_typing/typing_2024_12/_api_typing.py +5855 -0
  8. array_api_typing/typing_2024_12/_array_typing.py +1265 -0
  9. array_api_typing/typing_compat/__init__.py +12 -0
  10. array_api_typing/typing_compat/_api_typing.py +27 -0
  11. array_api_typing/typing_compat/_array_typing.py +36 -0
  12. array_api_typing/typing_extra/__init__.py +12 -0
  13. array_api_typing/typing_extra/_api_typing.py +651 -0
  14. array_api_typing/typing_extra/_at.py +87 -0
  15. xbarray/__init__.py +1 -0
  16. xbarray/backends/_cls_base.py +9 -0
  17. xbarray/backends/_implementations/_common/implementations.py +87 -0
  18. xbarray/backends/_implementations/jax/__init__.py +33 -0
  19. xbarray/backends/_implementations/jax/_extra.py +127 -0
  20. xbarray/backends/_implementations/jax/_typing.py +15 -0
  21. xbarray/backends/_implementations/jax/random.py +115 -0
  22. xbarray/backends/_implementations/numpy/__init__.py +25 -0
  23. xbarray/backends/_implementations/numpy/_extra.py +98 -0
  24. xbarray/backends/_implementations/numpy/_typing.py +14 -0
  25. xbarray/backends/_implementations/numpy/random.py +105 -0
  26. xbarray/backends/_implementations/pytorch/__init__.py +26 -0
  27. xbarray/backends/_implementations/pytorch/_extra.py +135 -0
  28. xbarray/backends/_implementations/pytorch/_typing.py +13 -0
  29. xbarray/backends/_implementations/pytorch/random.py +101 -0
  30. xbarray/backends/base.py +218 -0
  31. xbarray/backends/jax.py +19 -0
  32. xbarray/backends/numpy.py +19 -0
  33. xbarray/backends/pytorch.py +22 -0
  34. xbarray/jax.py +4 -0
  35. xbarray/numpy.py +4 -0
  36. xbarray/pytorch.py +4 -0
  37. xbarray/transformations/pointcloud/__init__.py +1 -0
  38. xbarray/transformations/pointcloud/base.py +449 -0
  39. xbarray/transformations/pointcloud/jax.py +24 -0
  40. xbarray/transformations/pointcloud/numpy.py +23 -0
  41. xbarray/transformations/pointcloud/pytorch.py +23 -0
  42. xbarray/transformations/rotation_conversions/__init__.py +1 -0
  43. xbarray/transformations/rotation_conversions/base.py +713 -0
  44. xbarray/transformations/rotation_conversions/jax.py +41 -0
  45. xbarray/transformations/rotation_conversions/numpy.py +41 -0
  46. xbarray/transformations/rotation_conversions/pytorch.py +41 -0
  47. xbarray-0.0.1a13.dist-info/METADATA +20 -0
  48. xbarray-0.0.1a13.dist-info/RECORD +51 -0
  49. xbarray-0.0.1a13.dist-info/WHEEL +5 -0
  50. xbarray-0.0.1a13.dist-info/licenses/LICENSE +21 -0
  51. xbarray-0.0.1a13.dist-info/top_level.txt +2 -0
@@ -0,0 +1,717 @@
1
+ from typing import Protocol, TypeVar, Optional, Any, Tuple, Union, Type, TypedDict, List, Literal, Sequence
2
+ from abc import abstractmethod
3
+ from ._array_typing import *
4
+ from ._api_return_typing import *
5
+
6
+ _NAMESPACE_ARRAY = TypeVar("_NAMESPACE_ARRAY", bound=Array)
7
+ _NAMESPACE_DEVICE = TypeVar("_NAMESPACE_DEVICE", bound=Device)
8
+ _NAMESPACE_DTYPE = TypeVar("_NAMESPACE_DTYPE", bound=DType)
9
+ class ArrayAPIFFTNamespace(Protocol[_NAMESPACE_ARRAY, _NAMESPACE_DEVICE, _NAMESPACE_DTYPE]):
10
+ """
11
+ FFT library API Stub
12
+ https://github.com/data-apis/array-api/blob/main/src/array_api_stubs/_2024_12/fft.py
13
+ """
14
+ @abstractmethod
15
+ def fft(
16
+ self,
17
+ x: _NAMESPACE_ARRAY,
18
+ /,
19
+ *,
20
+ n: Optional[int] = None,
21
+ axis: int = -1,
22
+ norm: Literal["backward", "ortho", "forward"] = "backward",
23
+ ) -> _NAMESPACE_ARRAY:
24
+ """
25
+ Computes the one-dimensional discrete Fourier transform.
26
+
27
+ .. note::
28
+ Applying the one-dimensional inverse discrete Fourier transform to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``ifft(fft(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (number of elements, axis, and normalization mode).
29
+
30
+ Parameters
31
+ ----------
32
+ x: _NAMESPACE_ARRAY
33
+ input array. Should have a complex floating-point data type.
34
+ n: Optional[int]
35
+ number of elements over which to compute the transform along the axis (dimension) specified by ``axis``. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``M``.
36
+
37
+ - If ``n`` is greater than ``M``, the axis specified by ``axis`` must be zero-padded to size ``n``.
38
+ - If ``n`` is less than ``M``, the axis specified by ``axis`` must be trimmed to size ``n``.
39
+ - If ``n`` equals ``M``, all elements along the axis specified by ``axis`` must be used when computing the transform.
40
+
41
+ Default: ``None``.
42
+ axis: int
43
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
44
+ norm: Literal['backward', 'ortho', 'forward']
45
+ normalization mode. Should be one of the following modes:
46
+
47
+ - ``'backward'``: no normalization.
48
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
49
+ - ``'forward'``: normalize by ``1/n``.
50
+
51
+ Default: ``'backward'``.
52
+
53
+ Returns
54
+ -------
55
+ out: _NAMESPACE_ARRAY
56
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have the same data type as ``x`` and must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n``.
57
+
58
+ Notes
59
+ -----
60
+
61
+ .. versionadded:: 2022.12
62
+
63
+ .. versionchanged:: 2023.12
64
+ Required the input array have a complex floating-point data type and required that the output array have the same data type as the input array.
65
+ """
66
+
67
+ @abstractmethod
68
+ def ifft(
69
+ self,
70
+ x: _NAMESPACE_ARRAY,
71
+ /,
72
+ *,
73
+ n: Optional[int] = None,
74
+ axis: int = -1,
75
+ norm: Literal["backward", "ortho", "forward"] = "backward",
76
+ ) -> _NAMESPACE_ARRAY:
77
+ """
78
+ Computes the one-dimensional inverse discrete Fourier transform.
79
+
80
+ .. note::
81
+ Applying the one-dimensional inverse discrete Fourier transform to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``ifft(fft(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (number of elements, axis, and normalization mode).
82
+
83
+ Parameters
84
+ ----------
85
+ x: _NAMESPACE_ARRAY
86
+ input array. Should have a complex floating-point data type.
87
+ n: Optional[int]
88
+ number of elements over which to compute the transform along the axis (dimension) specified by ``axis``. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``M``.
89
+
90
+ - If ``n`` is greater than ``M``, the axis specified by ``axis`` must be zero-padded to size ``n``.
91
+ - If ``n`` is less than ``M``, the axis specified by ``axis`` must be trimmed to size ``n``.
92
+ - If ``n`` equals ``M``, all elements along the axis specified by ``axis`` must be used when computing the transform.
93
+
94
+ Default: ``None``.
95
+ axis: int
96
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
97
+ norm: Literal['backward', 'ortho', 'forward']
98
+ normalization mode. Should be one of the following modes:
99
+
100
+ - ``'backward'``: normalize by ``1/n``.
101
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
102
+ - ``'forward'``: no normalization.
103
+
104
+ Default: ``'backward'``.
105
+
106
+ Returns
107
+ -------
108
+ out: _NAMESPACE_ARRAY
109
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have the same data type as ``x`` and must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n``.
110
+
111
+ Notes
112
+ -----
113
+
114
+ .. versionadded:: 2022.12
115
+
116
+ .. versionchanged:: 2023.12
117
+ Required the input array have a complex floating-point data type and required that the output array have the same data type as the input array.
118
+ """
119
+
120
+ @abstractmethod
121
+ def fftn(
122
+ self,
123
+ x: _NAMESPACE_ARRAY,
124
+ /,
125
+ *,
126
+ s: Optional[Sequence[int]] = None,
127
+ axes: Optional[Sequence[int]] = None,
128
+ norm: Literal["backward", "ortho", "forward"] = "backward",
129
+ ) -> _NAMESPACE_ARRAY:
130
+ """
131
+ Computes the n-dimensional discrete Fourier transform.
132
+
133
+ .. note::
134
+ Applying the n-dimensional inverse discrete Fourier transform to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``ifftn(fftn(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (sizes, axes, and normalization mode).
135
+
136
+ Parameters
137
+ ----------
138
+ x: _NAMESPACE_ARRAY
139
+ input array. Should have a complex floating-point data type.
140
+ s: Optional[Sequence[int]]
141
+ number of elements over which to compute the transform along the axes (dimensions) specified by ``axes``. Let ``i`` be the index of the ``n``-th axis specified by ``axes`` (i.e., ``i = axes[n]``) and ``M[i]`` be the size of the input array along axis ``i``. When ``s`` is ``None``, the function must set ``s`` equal to a sequence of integers such that ``s[i]`` equals ``M[i]`` for all ``i``.
142
+
143
+ - If ``s[i]`` is greater than ``M[i]``, axis ``i`` must be zero-padded to size ``s[i]``.
144
+ - If ``s[i]`` is less than ``M[i]``, axis ``i`` must be trimmed to size ``s[i]``.
145
+ - If ``s[i]`` equals ``M[i]`` or ``-1``, all elements along axis ``i`` must be used when computing the transform.
146
+
147
+ If ``s`` is not ``None``, ``axes`` must not be ``None``. Default: ``None``.
148
+ axes: Optional[Sequence[int]]
149
+ axes (dimensions) over which to compute the transform. A valid axis in ``axes`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an axis is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension).
150
+
151
+ If ``s`` is provided, the corresponding ``axes`` to be transformed must also be provided. If ``axes`` is ``None``, the function must compute the transform over all axes. Default: ``None``.
152
+
153
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
154
+ norm: Literal['backward', 'ortho', 'forward']
155
+ normalization mode. Should be one of the following modes:
156
+
157
+ - ``'backward'``: no normalization.
158
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
159
+ - ``'forward'``: normalize by ``1/n``.
160
+
161
+ where ``n = prod(s)`` is the logical FFT size.
162
+
163
+ Default: ``'backward'``.
164
+
165
+ Returns
166
+ -------
167
+ out: _NAMESPACE_ARRAY
168
+ an array transformed along the axes (dimensions) specified by ``axes``. The returned array must have the same data type as ``x`` and must have the same shape as ``x``, except for the axes specified by ``axes`` which must have size ``s[i]``.
169
+
170
+ Notes
171
+ -----
172
+
173
+ .. versionadded:: 2022.12
174
+
175
+ .. versionchanged:: 2023.12
176
+ Required the input array have a complex floating-point data type and required that the output array have the same data type as the input array.
177
+ """
178
+
179
+ @abstractmethod
180
+ def ifftn(
181
+ self,
182
+ x: _NAMESPACE_ARRAY,
183
+ /,
184
+ *,
185
+ s: Optional[Sequence[int]] = None,
186
+ axes: Optional[Sequence[int]] = None,
187
+ norm: Literal["backward", "ortho", "forward"] = "backward",
188
+ ) -> _NAMESPACE_ARRAY:
189
+ """
190
+ Computes the n-dimensional inverse discrete Fourier transform.
191
+
192
+ .. note::
193
+ Applying the n-dimensional inverse discrete Fourier transform to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``ifftn(fftn(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (sizes, axes, and normalization mode).
194
+
195
+ Parameters
196
+ ----------
197
+ x: _NAMESPACE_ARRAY
198
+ input array. Should have a complex floating-point data type.
199
+ s: Optional[Sequence[int]]
200
+ number of elements over which to compute the transform along the axes (dimensions) specified by ``axes``. Let ``i`` be the index of the ``n``-th axis specified by ``axes`` (i.e., ``i = axes[n]``) and ``M[i]`` be the size of the input array along axis ``i``. When ``s`` is ``None``, the function must set ``s`` equal to a sequence of integers such that ``s[i]`` equals ``M[i]`` for all ``i``.
201
+
202
+ - If ``s[i]`` is greater than ``M[i]``, axis ``i`` must be zero-padded to size ``s[i]``.
203
+ - If ``s[i]`` is less than ``M[i]``, axis ``i`` must be trimmed to size ``s[i]``.
204
+ - If ``s[i]`` equals ``M[i]`` or ``-1``, all elements along axis ``i`` must be used when computing the transform.
205
+
206
+ If ``s`` is not ``None``, ``axes`` must not be ``None``. Default: ``None``.
207
+ axes: Optional[Sequence[int]]
208
+ axes (dimensions) over which to compute the transform. A valid axis in ``axes`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an axis is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension).
209
+
210
+ If ``s`` is provided, the corresponding ``axes`` to be transformed must also be provided. If ``axes`` is ``None``, the function must compute the transform over all axes. Default: ``None``.
211
+
212
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
213
+ norm: Literal['backward', 'ortho', 'forward']
214
+ specify the normalization mode. Should be one of the following modes:
215
+
216
+ - ``'backward'``: normalize by ``1/n``.
217
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
218
+ - ``'forward'``: no normalization.
219
+
220
+ where ``n = prod(s)`` is the logical FFT size.
221
+
222
+ Default: ``'backward'``.
223
+
224
+ Returns
225
+ -------
226
+ out: _NAMESPACE_ARRAY
227
+ an array transformed along the axes (dimensions) specified by ``axes``. The returned array must have the same data type as ``x`` and must have the same shape as ``x``, except for the axes specified by ``axes`` which must have size ``s[i]``.
228
+
229
+ Notes
230
+ -----
231
+
232
+ .. versionadded:: 2022.12
233
+
234
+ .. versionchanged:: 2023.12
235
+ Required the input array have a complex floating-point data type and required that the output array have the same data type as the input array.
236
+ """
237
+
238
+ @abstractmethod
239
+ def rfft(
240
+ self,
241
+ x: _NAMESPACE_ARRAY,
242
+ /,
243
+ *,
244
+ n: Optional[int] = None,
245
+ axis: int = -1,
246
+ norm: Literal["backward", "ortho", "forward"] = "backward",
247
+ ) -> _NAMESPACE_ARRAY:
248
+ """
249
+ Computes the one-dimensional discrete Fourier transform for real-valued input.
250
+
251
+ .. note::
252
+ Applying the one-dimensional inverse discrete Fourier transform for real-valued input to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``irfft(rfft(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (axis and normalization mode) and consistent values for the number of elements over which to compute the transforms.
253
+
254
+ Parameters
255
+ ----------
256
+ x: _NAMESPACE_ARRAY
257
+ input array. Must have a real-valued floating-point data type.
258
+ n: Optional[int]
259
+ number of elements over which to compute the transform along the axis (dimension) specified by ``axis``. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``M``.
260
+
261
+ - If ``n`` is greater than ``M``, the axis specified by ``axis`` must be zero-padded to size ``n``.
262
+ - If ``n`` is less than ``M``, the axis specified by ``axis`` must be trimmed to size ``n``.
263
+ - If ``n`` equals ``M``, all elements along the axis specified by ``axis`` must be used when computing the transform.
264
+
265
+ Default: ``None``.
266
+ axis: int
267
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
268
+ norm: Literal['backward', 'ortho', 'forward']
269
+ normalization mode. Should be one of the following modes:
270
+
271
+ - ``'backward'``: no normalization.
272
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
273
+ - ``'forward'``: normalize by ``1/n``.
274
+
275
+ Default: ``'backward'``.
276
+
277
+ Returns
278
+ -------
279
+ out: _NAMESPACE_ARRAY
280
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have a complex floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``float64``, then the returned array must have a ``complex128`` data type). The returned array must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n//2 + 1``.
281
+
282
+ Notes
283
+ -----
284
+
285
+ .. versionadded:: 2022.12
286
+ """
287
+
288
+ @abstractmethod
289
+ def irfft(
290
+ self,
291
+ x: _NAMESPACE_ARRAY,
292
+ /,
293
+ *,
294
+ n: Optional[int] = None,
295
+ axis: int = -1,
296
+ norm: Literal["backward", "ortho", "forward"] = "backward",
297
+ ) -> _NAMESPACE_ARRAY:
298
+ """
299
+ Computes the one-dimensional inverse of ``rfft`` for complex-valued input.
300
+
301
+ .. note::
302
+ Applying the one-dimensional inverse discrete Fourier transform for real-valued input to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``irfft(rfft(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (axis and normalization mode) and consistent values for the number of elements over which to compute the transforms.
303
+
304
+ Parameters
305
+ ----------
306
+ x: _NAMESPACE_ARRAY
307
+ input array. Should have a complex floating-point data type.
308
+ n: Optional[int]
309
+ number of elements along the transformed axis (dimension) specified by ``axis`` in the **output array**. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``2*(M-1)``.
310
+
311
+ - If ``n//2+1`` is greater than ``M``, the axis of the input array specified by ``axis`` must be zero-padded to size ``n//2+1``.
312
+ - If ``n//2+1`` is less than ``M``, the axis of the input array specified by ``axis`` must be trimmed to size ``n//2+1``.
313
+ - If ``n//2+1`` equals ``M``, all elements along the axis of the input array specified by ``axis`` must be used when computing the transform.
314
+
315
+ Default: ``None``.
316
+ axis: int
317
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
318
+ norm: Literal['backward', 'ortho', 'forward']
319
+ normalization mode. Should be one of the following modes:
320
+
321
+ - ``'backward'``: normalize by ``1/n``.
322
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
323
+ - ``'forward'``: no normalization.
324
+
325
+ Default: ``'backward'``.
326
+
327
+ Returns
328
+ -------
329
+ out: _NAMESPACE_ARRAY
330
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then the returned array must have a ``float64`` data type). The returned array must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n``.
331
+
332
+ Notes
333
+ -----
334
+
335
+ - In order to return an array having an odd number of elements along the transformed axis, the function must be provided an odd integer for ``n``.
336
+
337
+ .. versionadded:: 2022.12
338
+
339
+ .. versionchanged:: 2023.12
340
+ Required the output array have a real-valued floating-point data type having the same precision as the input array.
341
+ """
342
+
343
+ @abstractmethod
344
+ def rfftn(
345
+ self,
346
+ x: _NAMESPACE_ARRAY,
347
+ /,
348
+ *,
349
+ s: Optional[Sequence[int]] = None,
350
+ axes: Optional[Sequence[int]] = None,
351
+ norm: Literal["backward", "ortho", "forward"] = "backward",
352
+ ) -> _NAMESPACE_ARRAY:
353
+ """
354
+ Computes the n-dimensional discrete Fourier transform for real-valued input.
355
+
356
+ .. note::
357
+ Applying the n-dimensional inverse discrete Fourier transform for real-valued input to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``irfftn(rfftn(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (axes and normalization mode) and consistent sizes.
358
+
359
+ Parameters
360
+ ----------
361
+ x: _NAMESPACE_ARRAY
362
+ input array. Must have a real-valued floating-point data type.
363
+ s: Optional[Sequence[int]]
364
+ number of elements over which to compute the transform along axes (dimensions) specified by ``axes``. Let ``i`` be the index of the ``n``-th axis specified by ``axes`` (i.e., ``i = axes[n]``) and ``M[i]`` be the size of the input array along axis ``i``. When ``s`` is ``None``, the function must set ``s`` equal to a sequence of integers such that ``s[i]`` equals ``M[i]`` for all ``i``.
365
+
366
+ - If ``s[i]`` is greater than ``M[i]``, axis ``i`` must be zero-padded to size ``s[i]``.
367
+ - If ``s[i]`` is less than ``M[i]``, axis ``i`` must be trimmed to size ``s[i]``.
368
+ - If ``s[i]`` equals ``M[i]`` or ``-1``, all elements along axis ``i`` must be used when computing the transform.
369
+
370
+ If ``s`` is not ``None``, ``axes`` must not be ``None``. Default: ``None``.
371
+ axes: Optional[Sequence[int]]
372
+ axes (dimensions) over which to compute the transform. A valid axis in ``axes`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an axis is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension).
373
+
374
+ If ``s`` is provided, the corresponding ``axes`` to be transformed must also be provided. If ``axes`` is ``None``, the function must compute the transform over all axes. Default: ``None``.
375
+
376
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
377
+ norm: Literal['backward', 'ortho', 'forward']
378
+ normalization mode. Should be one of the following modes:
379
+
380
+ - ``'backward'``: no normalization.
381
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
382
+ - ``'forward'``: normalize by ``1/n``.
383
+
384
+ where ``n = prod(s)``, the logical FFT size.
385
+
386
+ Default: ``'backward'``.
387
+
388
+ Returns
389
+ -------
390
+ out: _NAMESPACE_ARRAY
391
+ an array transformed along the axes (dimension) specified by ``axes``. The returned array must have a complex floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``float64``, then the returned array must have a ``complex128`` data type). The returned array must have the same shape as ``x``, except for the last transformed axis which must have size ``s[-1]//2 + 1`` and the remaining transformed axes which must have size ``s[i]``.
392
+
393
+ Notes
394
+ -----
395
+
396
+ .. versionadded:: 2022.12
397
+ """
398
+
399
+ @abstractmethod
400
+ def irfftn(
401
+ self,
402
+ x: _NAMESPACE_ARRAY,
403
+ /,
404
+ *,
405
+ s: Optional[Sequence[int]] = None,
406
+ axes: Optional[Sequence[int]] = None,
407
+ norm: Literal["backward", "ortho", "forward"] = "backward",
408
+ ) -> _NAMESPACE_ARRAY:
409
+ """
410
+ Computes the n-dimensional inverse of ``rfftn`` for complex-valued input.
411
+
412
+ .. note::
413
+ Applying the n-dimensional inverse discrete Fourier transform for real-valued input to the output of this function must return the original (i.e., non-transformed) input array within numerical accuracy (i.e., ``irfftn(rfftn(x)) == x``), provided that the transform and inverse transform are performed with the same arguments (axes and normalization mode) and consistent sizes.
414
+
415
+ Parameters
416
+ ----------
417
+ x: _NAMESPACE_ARRAY
418
+ input array. Should have a complex floating-point data type.
419
+ s: Optional[Sequence[int]]
420
+ number of elements along the transformed axes (dimensions) specified by ``axes`` in the **output array**. Let ``i`` be the index of the ``n``-th axis specified by ``axes`` (i.e., ``i = axes[n]``) and ``M[i]`` be the size of the input array along axis ``i``. When ``s`` is ``None``, the function must set ``s`` equal to a sequence of integers such that ``s[i]`` equals ``M[i]`` for all ``i``, except for the last transformed axis in which ``s[i]`` equals ``2*(M[i]-1)``. For each ``i``, let ``n`` equal ``s[i]``, except for the last transformed axis in which ``n`` equals ``s[i]//2+1``.
421
+
422
+ - If ``n`` is greater than ``M[i]``, axis ``i`` of the input array must be zero-padded to size ``n``.
423
+ - If ``n`` is less than ``M[i]``, axis ``i`` of the input array must be trimmed to size ``n``.
424
+ - If ``n`` equals ``M[i]`` or ``-1``, all elements along axis ``i`` of the input array must be used when computing the transform.
425
+
426
+ If ``s`` is not ``None``, ``axes`` must not be ``None``. Default: ``None``.
427
+ axes: Optional[Sequence[int]]
428
+ axes (dimensions) over which to compute the transform. A valid axis in ``axes`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an axis is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension).
429
+
430
+ If ``s`` is provided, the corresponding ``axes`` to be transformed must also be provided. If ``axes`` is ``None``, the function must compute the transform over all axes. Default: ``None``.
431
+
432
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
433
+ norm: Literal['backward', 'ortho', 'forward']
434
+ normalization mode. Should be one of the following modes:
435
+
436
+ - ``'backward'``: normalize by ``1/n``.
437
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
438
+ - ``'forward'``: no normalization.
439
+
440
+ where ``n = prod(s)`` is the logical FFT size.
441
+
442
+ Default: ``'backward'``.
443
+
444
+ Returns
445
+ -------
446
+ out: _NAMESPACE_ARRAY
447
+ an array transformed along the axes (dimension) specified by ``axes``. The returned array must have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then the returned array must have a ``float64`` data type). The returned array must have the same shape as ``x``, except for the transformed axes which must have size ``s[i]``.
448
+
449
+ Notes
450
+ -----
451
+
452
+ - In order to return an array having an odd number of elements along the last transformed axis, the function must be provided an odd integer for ``s[-1]``.
453
+
454
+ .. versionadded:: 2022.12
455
+
456
+ .. versionchanged:: 2023.12
457
+ Required the output array have a real-valued floating-point data type having the same precision as the input array.
458
+ """
459
+
460
+ @abstractmethod
461
+ def hfft(
462
+ self,
463
+ x: _NAMESPACE_ARRAY,
464
+ /,
465
+ *,
466
+ n: Optional[int] = None,
467
+ axis: int = -1,
468
+ norm: Literal["backward", "ortho", "forward"] = "backward",
469
+ ) -> _NAMESPACE_ARRAY:
470
+ """
471
+ Computes the one-dimensional discrete Fourier transform of a signal with Hermitian symmetry.
472
+
473
+ Parameters
474
+ ----------
475
+ x: _NAMESPACE_ARRAY
476
+ input array. Should have a complex floating-point data type.
477
+ n: Optional[int]
478
+ number of elements along the transformed axis (dimension) specified by ``axis`` in the **output array**. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``2*(M-1)``.
479
+
480
+ - If ``n//2+1`` is greater than ``M``, the axis of the input array specified by ``axis`` must be zero-padded to length ``n//2+1``.
481
+ - If ``n//2+1`` is less than ``M``, the axis of the input array specified by ``axis`` must be trimmed to size ``n//2+1``.
482
+ - If ``n//2+1`` equals ``M``, all elements along the axis of the input array specified by ``axis`` must be used when computing the transform.
483
+
484
+ Default: ``None``.
485
+ axis: int
486
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
487
+ norm: Literal['backward', 'ortho', 'forward']
488
+ normalization mode. Should be one of the following modes:
489
+
490
+ - ``'backward'``: no normalization.
491
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
492
+ - ``'forward'``: normalize by ``1/n``.
493
+
494
+ Default: ``'backward'``.
495
+
496
+ Returns
497
+ -------
498
+ out: _NAMESPACE_ARRAY
499
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have a real-valued floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``complex128``, then the returned array must have a ``float64`` data type). The returned array must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n``.
500
+
501
+ Notes
502
+ -----
503
+
504
+ .. versionadded:: 2022.12
505
+
506
+ .. versionchanged:: 2023.12
507
+ Required the input array to have a complex floating-point data type and required that the output array have a real-valued data type having the same precision as the input array.
508
+ """
509
+
510
+ @abstractmethod
511
+ def ihfft(
512
+ self,
513
+ x: _NAMESPACE_ARRAY,
514
+ /,
515
+ *,
516
+ n: Optional[int] = None,
517
+ axis: int = -1,
518
+ norm: Literal["backward", "ortho", "forward"] = "backward",
519
+ ) -> _NAMESPACE_ARRAY:
520
+ """
521
+ Computes the one-dimensional inverse discrete Fourier transform of a signal with Hermitian symmetry.
522
+
523
+ Parameters
524
+ ----------
525
+ x: _NAMESPACE_ARRAY
526
+ input array. Must have a real-valued floating-point data type.
527
+ n: Optional[int]
528
+ number of elements over which to compute the transform along the axis (dimension) specified by ``axis``. Let ``M`` be the size of the input array along the axis specified by ``axis``. When ``n`` is ``None``, the function must set ``n`` equal to ``M``.
529
+
530
+ - If ``n`` is greater than ``M``, the axis specified by ``axis`` must be zero-padded to size ``n``.
531
+ - If ``n`` is less than ``M``, the axis specified by ``axis`` must be trimmed to size ``n``.
532
+ - If ``n`` equals ``M``, all elements along the axis specified by ``axis`` must be used when computing the transform.
533
+
534
+ Default: ``None``.
535
+ axis: int
536
+ axis (dimension) of the input array over which to compute the transform. A valid ``axis`` must be an integer on the interval ``[-N, N)``, where ``N`` is the rank (number of dimensions) of ``x``. If an ``axis`` is specified as a negative integer, the function must determine the axis along which to compute the transform by counting backward from the last dimension (where ``-1`` refers to the last dimension). Default: ``-1``.
537
+ norm: Literal['backward', 'ortho', 'forward']
538
+ normalization mode. Should be one of the following modes:
539
+
540
+ - ``'backward'``: normalize by ``1/n``.
541
+ - ``'ortho'``: normalize by ``1/sqrt(n)`` (i.e., make the FFT orthonormal).
542
+ - ``'forward'``: no normalization.
543
+
544
+ Default: ``'backward'``.
545
+
546
+ Returns
547
+ -------
548
+ out: _NAMESPACE_ARRAY
549
+ an array transformed along the axis (dimension) specified by ``axis``. The returned array must have a complex floating-point data type whose precision matches the precision of ``x`` (e.g., if ``x`` is ``float64``, then the returned array must have a ``complex128`` data type). The returned array must have the same shape as ``x``, except for the axis specified by ``axis`` which must have size ``n//2 + 1``.
550
+
551
+ Notes
552
+ -----
553
+
554
+ .. versionadded:: 2022.12
555
+ """
556
+
557
+ @abstractmethod
558
+ def fftfreq(
559
+ self,
560
+ n: int,
561
+ /,
562
+ *,
563
+ d: float = 1.0,
564
+ dtype: Optional[_NAMESPACE_DTYPE] = None,
565
+ device: Optional[_NAMESPACE_DEVICE] = None,
566
+ ) -> _NAMESPACE_ARRAY:
567
+ """
568
+ Computes the discrete Fourier transform sample frequencies.
569
+
570
+ For a Fourier transform of length ``n`` and length unit of ``d``, the frequencies are described as:
571
+
572
+ .. code-block::
573
+
574
+ f = [0, 1, ..., n/2-1, -n/2, ..., -1] / (d*n) # if n is even
575
+ f = [0, 1, ..., (n-1)/2, -(n-1)/2, ..., -1] / (d*n) # if n is odd
576
+
577
+ Parameters
578
+ ----------
579
+ n: int
580
+ window length.
581
+ d: float
582
+ sample spacing between individual samples of the Fourier transform input. Default: ``1.0``.
583
+ dtype: Optional[dtype]
584
+ output array data type. Must be a real-valued floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default real-valued floating-point data type. Default: ``None``.
585
+ device: Optional[device]
586
+ device on which to place the created array. Default: ``None``.
587
+
588
+ Returns
589
+ -------
590
+ out: _NAMESPACE_ARRAY
591
+ an array of shape ``(n,)`` containing the sample frequencies.
592
+
593
+ Notes
594
+ -----
595
+
596
+ .. versionadded:: 2022.12
597
+
598
+ .. versionchanged:: 2023.12
599
+ Required the output array have the default real-valued floating-point data type.
600
+
601
+ .. versionchanged:: 2024.12
602
+ Added ``dtype`` keyword argument support.
603
+ """
604
+
605
+ @abstractmethod
606
+ def rfftfreq(
607
+ self,
608
+ n: int,
609
+ /,
610
+ *,
611
+ d: float = 1.0,
612
+ dtype: Optional[_NAMESPACE_DTYPE] = None,
613
+ device: Optional[_NAMESPACE_DEVICE] = None,
614
+ ) -> _NAMESPACE_ARRAY:
615
+ """
616
+ Computes the discrete Fourier transform sample frequencies (for ``rfft`` and ``irfft``).
617
+
618
+ For a Fourier transform of length ``n`` and length unit of ``d``, the frequencies are described as:
619
+
620
+ .. code-block::
621
+
622
+ f = [0, 1, ..., n/2-1, n/2] / (d*n) # if n is even
623
+ f = [0, 1, ..., (n-1)/2-1, (n-1)/2] / (d*n) # if n is odd
624
+
625
+ The Nyquist frequency component is considered to be positive.
626
+
627
+ Parameters
628
+ ----------
629
+ n: int
630
+ window length.
631
+ d: float
632
+ sample spacing between individual samples of the Fourier transform input. Default: ``1.0``.
633
+ dtype: Optional[dtype]
634
+ output array data type. Must be a real-valued floating-point data type. If ``dtype`` is ``None``, the output array data type must be the default real-valued floating-point data type. Default: ``None``.
635
+ device: Optional[device]
636
+ device on which to place the created array. Default: ``None``.
637
+
638
+ Returns
639
+ -------
640
+ out: _NAMESPACE_ARRAY
641
+ an array of shape ``(n//2+1,)`` containing the sample frequencies.
642
+
643
+ Notes
644
+ -----
645
+
646
+ .. versionadded:: 2022.12
647
+
648
+ .. versionchanged:: 2023.12
649
+ Required the output array have the default real-valued floating-point data type.
650
+
651
+ .. versionchanged:: 2024.12
652
+ Added ``dtype`` keyword argument support.
653
+ """
654
+
655
+ @abstractmethod
656
+ def fftshift(
657
+ self,
658
+ x: _NAMESPACE_ARRAY, /, *, axes: Optional[Union[int, Sequence[int]]] = None
659
+ ) -> _NAMESPACE_ARRAY:
660
+ """
661
+ Shifts the zero-frequency component to the center of the spectrum.
662
+
663
+ This function swaps half-spaces for all axes (dimensions) specified by ``axes``.
664
+
665
+ .. note::
666
+ ``out[0]`` is the Nyquist component only if the length of the input is even.
667
+
668
+ Parameters
669
+ ----------
670
+ x: _NAMESPACE_ARRAY
671
+ input array. Should have a floating-point data type.
672
+ axes: Optional[Union[int, Sequence[int]]]
673
+ axes over which to shift. If ``None``, the function must shift all axes. Default: ``None``.
674
+
675
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
676
+
677
+ Returns
678
+ -------
679
+ out: _NAMESPACE_ARRAY
680
+ the shifted array. The returned array must have the same data type and shape as ``x``.
681
+
682
+ Notes
683
+ -----
684
+
685
+ .. versionadded:: 2022.12
686
+ """
687
+
688
+ @abstractmethod
689
+ def ifftshift(
690
+ self,
691
+ x: _NAMESPACE_ARRAY, /, *, axes: Optional[Union[int, Sequence[int]]] = None
692
+ ) -> _NAMESPACE_ARRAY:
693
+ """
694
+ Inverse of ``fftshift``.
695
+
696
+ .. note::
697
+ Although identical for even-length ``x``, ``fftshift`` and ``ifftshift`` differ by one sample for odd-length ``x``.
698
+
699
+ Parameters
700
+ ----------
701
+ x: _NAMESPACE_ARRAY
702
+ input array. Should have a floating-point data type.
703
+ axes: Optional[Union[int, Sequence[int]]]
704
+ axes over which to perform the inverse shift. If ``None``, the function must shift all axes. Default: ``None``.
705
+
706
+ If ``axes`` contains two or more entries which resolve to the same axis (i.e., resolved axes are not unique), the behavior is unspecified and thus implementation-defined.
707
+
708
+ Returns
709
+ -------
710
+ out: _NAMESPACE_ARRAY
711
+ the shifted array. The returned array must have the same data type and shape as ``x``.
712
+
713
+ Notes
714
+ -----
715
+
716
+ .. versionadded:: 2022.12
717
+ """