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
{{ message }}
Repository navigation
Commit 59656ab
Browse filesBrowse the repository at this point in the historyBrowse files
feat!: add fromIndex support to blas/ext/base/ndarray/slast-index-of-falsy
BREAKING CHANGE: add `fromIndex` support
To maintain previous behavior, provide an additional zero-dimensional ndarray containing the index of the last element.
PR-URL: #14653
Reviewed-by: Athan Reines <kgryte@gmail.com>
Closes: stdlib-js/metr-issue-tracker#1198
Copy file name to clipboardExpand all lines: lib/node_modules/@stdlib/blas/ext/base/ndarray/slast-index-of-falsy/README.md
+23-4Lines changed: 23 additions & 4 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -42,25 +42,38 @@ Returns the index of the last falsy element in a one-dimensional single-precisio
42
42
43
43
```javascript
44
44
var Float32Vector =require( '@stdlib/ndarray/vector/float32' );
45
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
45
46
46
47
var x =newFloat32Vector( [ 1.0, 0.0, 3.0, 0.0 ] );
47
48
48
-
var idx =slastIndexOfFalsy( [ x ] );
49
+
var fromIndex =scalar2ndarray( 3, {
50
+
'dtype':'generic'
51
+
});
52
+
53
+
var idx =slastIndexOfFalsy( [ x, fromIndex ] );
49
54
// returns 3
50
55
```
51
56
52
57
The function has the following parameters:
53
58
54
-
-**arrays**: array-like object containing a one-dimensional input ndarray.
59
+
-**arrays**: array-like object containing the following ndarrays:
60
+
61
+
- a one-dimensional input ndarray.
62
+
- a zero-dimensional ndarray containing the index from which to begin searching.
55
63
56
64
If the function is unable to find a falsy element, the function returns `-1`.
57
65
58
66
```javascript
59
67
var Float32Vector =require( '@stdlib/ndarray/vector/float32' );
68
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
60
69
61
70
var x =newFloat32Vector( [ 1.0, 2.0, 3.0, 4.0 ] );
62
71
63
-
var idx =slastIndexOfFalsy( [ x ] );
72
+
var fromIndex =scalar2ndarray( 3, {
73
+
'dtype':'generic'
74
+
});
75
+
76
+
var idx =slastIndexOfFalsy( [ x, fromIndex ] );
64
77
// returns -1
65
78
```
66
79
@@ -73,6 +86,7 @@ var idx = slastIndexOfFalsy( [ x ] );
73
86
## Notes
74
87
75
88
- The function treats `NaN` values as falsy.
89
+
- If a specified starting search index is negative, the function resolves the starting search index by counting backward from the last element (where `-1` refers to the last element).
76
90
77
91
</section>
78
92
@@ -86,6 +100,7 @@ var idx = slastIndexOfFalsy( [ x ] );
86
100
87
101
```javascript
88
102
var bernoulli =require( '@stdlib/random/bernoulli' );
103
+
var scalar2ndarray =require( '@stdlib/ndarray/from-scalar' );
89
104
var ndarray2array =require( '@stdlib/ndarray/to-array' );
90
105
var slastIndexOfFalsy =require( '@stdlib/blas/ext/base/ndarray/slast-index-of-falsy' );
0 commit comments