@@ -2375,8 +2375,9 @@ def tril_indices(
2375
2375
Returns
2376
2376
-------
2377
2377
inds : tuple of dpnp.ndarray
2378
- The indices for the triangle. The returned tuple contains two arrays,
2379
- each with the indices along one dimension of the array.
2378
+ The row and column indices, respectively. The row indices are sorted in
2379
+ non-decreasing order, and the corresponding column indices are strictly
2380
+ increasing for each row.
2380
2381
2381
2382
See Also
2382
2383
--------
@@ -2394,7 +2395,13 @@ def tril_indices(
2394
2395
2395
2396
>>> import dpnp as np
2396
2397
>>> il1 = np.tril_indices(4)
2397
- >>> il2 = np.tril_indices(4, 2)
2398
+ >>> il1
2399
+ (array([0, 1, 1, 2, 2, 2, 3, 3, 3, 3]),
2400
+ array([0, 0, 1, 0, 1, 2, 0, 1, 2, 3]))
2401
+
2402
+ Note that row indices (first array) are non-decreasing, and the
2403
+ corresponding column indices (second array) are strictly increasing for
2404
+ each row.
2398
2405
2399
2406
Here is how they can be used with a sample array:
2400
2407
@@ -2421,6 +2428,7 @@ def tril_indices(
2421
2428
2422
2429
These cover almost the whole array (two diagonals right of the main one):
2423
2430
2431
+ >>> il2 = np.tril_indices(4, 2)
2424
2432
>>> a[il2] = -10
2425
2433
>>> a
2426
2434
array([[-10, -10, -10, 3],
@@ -2584,9 +2592,9 @@ def triu_indices(
2584
2592
Returns
2585
2593
-------
2586
2594
inds : tuple of dpnp.ndarray
2587
- The indices for the triangle . The returned tuple contains two arrays,
2588
- each with the indices along one dimension of the array. Can be used
2589
- to slice a ndarray of shape(`n`, `n`) .
2595
+ The row and column indices, respectively . The row indices are sorted in
2596
+ non-decreasing order, and the corresponding column indices are strictly
2597
+ increasing for each row .
2590
2598
2591
2599
See Also
2592
2600
--------
@@ -2604,7 +2612,13 @@ def triu_indices(
2604
2612
2605
2613
>>> import dpnp as np
2606
2614
>>> iu1 = np.triu_indices(4)
2607
- >>> iu2 = np.triu_indices(4, 2)
2615
+ >>> iu1
2616
+ (array([0, 0, 0, 0, 1, 1, 1, 2, 2, 3]),
2617
+ array([0, 1, 2, 3, 1, 2, 3, 2, 3, 3]))
2618
+
2619
+ Note that row indices (first array) are non-decreasing, and the
2620
+ corresponding column indices (second array) are strictly increasing for
2621
+ each row.
2608
2622
2609
2623
Here is how they can be used with a sample array:
2610
2624
@@ -2632,6 +2646,7 @@ def triu_indices(
2632
2646
These cover only a small part of the whole array (two diagonals right
2633
2647
of the main one):
2634
2648
2649
+ >>> iu2 = np.triu_indices(4, 2)
2635
2650
>>> a[iu2] = -10
2636
2651
>>> a
2637
2652
array([[ -1, -1, -10, -10],
0 commit comments