You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
device on which to place the created array. Default: ``None``.
20
20
21
+
22
+
.. note::
23
+
This function cannot guarantee that the interval does not include the ``stop`` value in those cases where ``step`` is not an integer and floating-point rounding errors affect the length of the output array.
24
+
21
25
Returns
22
26
-------
23
27
out: array
24
28
a one-dimensional array containing evenly spaced values. The length of the output array must be ``ceil((stop-start)/step)`` if ``stop - start`` and ``step`` have the same sign, and length ``0`` otherwise.
25
-
26
-
Notes
27
-
-----
28
-
- This function cannot guarantee that the interval does not include the ``stop`` value in those cases where ``step`` is not an integer and floating-point rounding errors affect the length of the output array.
object to be converted to an array. May be a Python scalar, a (possibly nested) sequence of Python scalars, or an object supporting the Python buffer protocol.
39
39
40
-
**Tip**
40
+
.. admonition:: Tip
41
+
:class: important
42
+
43
+
An object supporting the buffer protocol can be turned into a memoryview through ``memoryview(obj)``.
41
44
42
-
An object supporting the buffer protocol can be turned into a memoryview through ``memoryview(obj)``.
43
45
dtype: Optional[dtype]
44
46
output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from the data type(s) in ``obj``. If all input values are Python scalars, then
- if one or more values are ``float``\s, the output data type must be the default floating-point data type.
49
51
50
52
Default: ``None``.
53
+
54
+
.. admonition:: Note
55
+
:class: note
56
+
57
+
If ``dtype`` is not ``None``, then array conversions should obey :ref:`type-promotion` rules. Conversions not specified according to :ref:`type-promotion` rules may or may not be permitted by a conforming array library. To perform an explicit cast, use :ref:`function-astype`.
58
+
51
59
device: Optional[device]
52
60
device on which to place the created array. If ``device`` is ``None`` and ``x`` is an array, the output array device must be inferred from ``x``. Default: ``None``.
- If ``dtype`` is not ``None``, then array conversions should obey :ref:`type-promotion` rules. Conversions not specified according to :ref:`type-promotion` rules may or may not be permitted by a conforming array library. To perform an explicit cast, use :ref:`function-astype`.
output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``fill_value``. If the fill value is an ``int``, the output array data type must be the default integer data type. If the fill value is a ``float``, the output array data type must be the default floating-point data type. If the fill value is a ``bool``, the output array must have boolean data type. Default: ``None``.
163
+
164
+
.. note::
165
+
If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved default output array data type, behavior is left unspecified and, thus, implementation-defined.
166
+
158
167
device: Optional[device]
159
168
device on which to place the created array. Default: ``None``.
160
169
161
170
Returns
162
171
-------
163
172
out: array
164
173
an array where every element is equal to ``fill_value``.
165
-
166
-
Notes
167
-
-----
168
-
- If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved default output array data type, behavior is left unspecified and, thus, implementation-defined.
output array data type. If ``dtype`` is ``None``, the output array data type must be inferred from ``x``. Default: ``None``.
188
+
189
+
.. note::
190
+
If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved output array data type, behavior is unspecified and, thus, implementation-defined.
191
+
192
+
.. note::
193
+
If ``dtype`` is ``None`` and the ``fill_value`` has a data type (``int`` or ``float``) which is not of the same data type kind as the resolved output array data type (see :ref:`type-promotion`), behavior is unspecified and, thus, implementation-defined.
194
+
183
195
device: Optional[device]
184
196
device on which to place the created array. If ``device`` is ``None``, the output array device must be inferred from ``x``. Default: ``None``.
185
197
186
198
Returns
187
199
-------
188
200
out: array
189
201
an array having the same shape as ``x`` and where every element is equal to ``fill_value``.
190
-
191
-
Notes
192
-
-----
193
-
- If ``dtype`` is ``None`` and the ``fill_value`` exceeds the precision of the resolved output array data type, behavior is unspecified and, thus, implementation-defined.
194
-
- If ``dtype`` is ``None`` and the ``fill_value`` has a data type (``int`` or ``float``) which is not of the same data type kind as the resolved output array data type (see :ref:`type-promotion`), behavior is unspecified and, thus, implementation-defined.
the end of the interval. If ``endpoint`` is ``False``, the function must generate a sequence of ``num+1`` evenly spaced numbers starting with ``start`` and ending with ``stop`` and exclude the ``stop`` from the returned array such that the returned array consists of evenly spaced numbers over the half-open interval ``[start, stop)``. If ``endpoint`` is ``True``, the output array must consist of evenly spaced numbers over the closed interval ``[start, stop]``. Default: ``True``.
214
+
215
+
.. note::
216
+
The step size changes when `endpoint` is `False`.
217
+
207
218
num: int
208
219
number of samples. Must be a non-negative integer value; otherwise, the function must raise an exception.
Returns the lower triangular part of a matrix (or a stack of matrices) ``x``.
293
300
301
+
.. note::
302
+
The lower triangular part of the matrix is defined as the elements on and below the specified diagonal ``k``.
303
+
294
304
Parameters
295
305
----------
296
306
x: array
297
307
input array having shape ``(..., M, N)`` and whose innermost two dimensions form ``MxN`` matrices.
298
308
k: int
299
309
diagonal above which to zero elements. If ``k = 0``, the diagonal is the main diagonal. If ``k < 0``, the diagonal is below the main diagonal. If ``k > 0``, the diagonal is above the main diagonal. Default: ``0``.
300
310
311
+
.. note::
312
+
The main diagonal is defined as the set of indices ``{(i, i)}`` for ``i`` on the interval ``[0, min(M, N) - 1]``.
313
+
301
314
Returns
302
315
-------
303
316
out: array
304
317
an array containing the lower triangular part(s). The returned array must have the same shape and data type as ``x``. All elements above the specified diagonal ``k`` must be zeroed. The returned array should be allocated on the same device as ``x``.
305
-
306
-
Notes
307
-
-----
308
-
- The lower triangular part of the matrix is defined as the elements on and below the specified diagonal ``k``.
309
-
- The main diagonal is defined as the set of indices ``{(i, i)}`` for ``i`` on the interval ``[0, min(M, N) - 1]``.
310
318
"""
311
319
312
320
deftriu(x: array, /, *, k: int=0) ->array:
313
321
"""
314
322
Returns the upper triangular part of a matrix (or a stack of matrices) ``x``.
315
323
324
+
.. note::
325
+
The upper triangular part of the matrix is defined as the elements on and above the specified diagonal ``k``.
326
+
316
327
Parameters
317
328
----------
318
329
x: array
319
330
input array having shape ``(..., M, N)`` and whose innermost two dimensions form ``MxN`` matrices.
320
331
k: int
321
332
diagonal below which to zero elements. If ``k = 0``, the diagonal is the main diagonal. If ``k < 0``, the diagonal is below the main diagonal. If ``k > 0``, the diagonal is above the main diagonal. Default: ``0``.
322
333
334
+
.. note::
335
+
The main diagonal is defined as the set of indices ``{(i, i)}`` for ``i`` on the interval ``[0, min(M, N) - 1]``.
336
+
323
337
Returns
324
338
-------
325
339
out: array
326
340
an array containing the upper triangular part(s). The returned array must have the same shape and data type as ``x``. All elements below the specified diagonal ``k`` must be zeroed. The returned array should be allocated on the same device as ``x``.
327
-
328
-
Notes
329
-
-----
330
-
- The upper triangular part of the matrix is defined as the elements on and above the specified diagonal ``k``.
331
-
- The main diagonal is defined as the set of indices ``{(i, i)}`` for ``i`` on the interval ``[0, min(M, N) - 1]``.
0 commit comments