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
Copy file name to clipboardExpand all lines: spec/API_specification/creation_functions.md
+70-12
Original file line number
Diff line number
Diff line change
@@ -41,7 +41,7 @@ This function cannot guarantee that the interval does not include the `stop` val
41
41
42
42
-**device**: _Optional\[<device>]_
43
43
44
-
- device to place the created array on, if given. Default: `None`.
44
+
- device on which to place the created array. Default: `None`.
45
45
46
46
#### Returns
47
47
@@ -72,7 +72,7 @@ Convert the input to an array.
72
72
73
73
-**device**: _Optional\[<device>]_
74
74
75
-
- device to place the created array on, if given. Default: `None`.
75
+
- device on which to place the created array. Default: `None`.
76
76
77
77
-**copy**: _Optional\[ bool ]_
78
78
@@ -102,7 +102,7 @@ Returns an uninitialized array having a specified `shape`.
102
102
103
103
-**device**: _Optional\[<device>]_
104
104
105
-
- device to place the created array on, if given. Default: `None`.
105
+
- device on which to place the created array. Default: `None`.
106
106
107
107
#### Returns
108
108
@@ -127,7 +127,7 @@ Returns an uninitialized array with the same `shape` as an input array `x`.
127
127
128
128
-**device**: _Optional\[<device>]_
129
129
130
-
- device to place the created array on, if given. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
130
+
- device on which to place the created array. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
131
131
132
132
#### Returns
133
133
@@ -160,7 +160,7 @@ Returns a two-dimensional array with ones on the `k`th diagonal and zeros elsewh
160
160
161
161
-**device**: _Optional\[<device>]_
162
162
163
-
- device to place the created array on, if given. Default: `None`.
163
+
- device on which to place the created array. Default: `None`.
164
164
165
165
#### Returns
166
166
@@ -214,7 +214,7 @@ Returns a new array having a specified `shape` and filled with `fill_value`.
214
214
215
215
- **device**: _Optional\[ <device> ]_
216
216
217
-
- device to place the created array on, if given. Default: `None`.
217
+
- device on which to place the created array. Default: `None`.
218
218
219
219
#### Returns
220
220
@@ -247,7 +247,7 @@ Returns a new array filled with `fill_value` and having the same `shape` as an i
247
247
248
248
- **device**: _Optional\[ <device> ]_
249
249
250
-
- device to place the created array on, if given. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
250
+
- device on which to place the created array. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
251
251
252
252
#### Returns
253
253
@@ -285,7 +285,7 @@ Returns evenly spaced numbers over a specified interval.
285
285
286
286
- **device**: _Optional\[ <device> ]_
287
287
288
-
- device to place the created array on, if given. Default: `None`.
288
+
- device on which to place the created array. Default: `None`.
289
289
290
290
- **endpoint**: _bool_
291
291
@@ -345,7 +345,7 @@ Returns a new array having a specified `shape` and filled with ones.
345
345
346
346
- **device**: _Optional\[ <device> ]_
347
347
348
-
- device to place the created array on, if given. Default: `None`.
348
+
- device on which to place the created array. Default: `None`.
349
349
350
350
#### Returns
351
351
@@ -370,14 +370,72 @@ Returns a new array filled with ones and having the same `shape` as an input arr
370
370
371
371
- **device**: _Optional\[ <device> ]_
372
372
373
-
- device to place the created array on, if given. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
373
+
- device on which to place the created array. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
374
374
375
375
#### Returns
376
376
377
377
- **out**: _<array>_
378
378
379
379
- an array having the same shape as `x` and filled with ones.
380
380
381
+
(function-tril)=
382
+
### tril(x, /, *, k=0)
383
+
384
+
Returns the lower triangular part of a matrix (or a stack of matrices) `x`.
385
+
386
+
```{note}
387
+
The lower triangular part of the matrix is defined as the elements on and below the specified diagonal `k`.
388
+
```
389
+
390
+
#### Parameters
391
+
392
+
-**x**: _<array>_
393
+
394
+
- input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices.
395
+
396
+
-**k**: _int_
397
+
398
+
- 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`.
399
+
400
+
```{note}
401
+
The main diagonal is defined as the set of indices `{(i, i)}` for `i` on the interval `[0, min(M, N) - 1]`.
402
+
```
403
+
404
+
#### Returns
405
+
406
+
- **out**: _<array>_
407
+
408
+
- 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`.
409
+
410
+
(function-triu)=
411
+
### triu(x, /, *, k=0)
412
+
413
+
Returns the upper triangular part of a matrix (or a stack of matrices) `x`.
414
+
415
+
```{note}
416
+
The upper triangular part of the matrix is defined as the elements on and above the specified diagonal `k`.
417
+
```
418
+
419
+
#### Parameters
420
+
421
+
-**x**: _<array>_
422
+
423
+
- input array having shape `(..., M, N)` and whose innermost two dimensions form `MxN` matrices.
424
+
425
+
-**k**: _int_
426
+
427
+
- 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`.
428
+
429
+
```{note}
430
+
The main diagonal is defined as the set of indices `{(i, i)}` for `i` on the interval `[0, min(M, N) - 1]`.
431
+
```
432
+
433
+
#### Returns
434
+
435
+
- **out**: _<array>_
436
+
437
+
- 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`.
438
+
381
439
(function-zeros)=
382
440
### zeros(shape, *, dtype=None, device=None)
383
441
@@ -395,7 +453,7 @@ Returns a new array having a specified `shape` and filled with zeros.
395
453
396
454
- **device**: _Optional\[ <device> ]_
397
455
398
-
- device to place the created array on, if given. Default: `None`.
456
+
- device on which to place the created array. Default: `None`.
399
457
400
458
#### Returns
401
459
@@ -420,7 +478,7 @@ Returns a new array filled with zeros and having the same `shape` as an input ar
420
478
421
479
- **device**: _Optional\[ <device> ]_
422
480
423
-
- device to place the created array on, if given. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
481
+
- device on which to place the created array. If `device` is `None`, the default device must be used, not `x.device`. Default: `None`.
0 commit comments