Skip to content

Commit 28ed5ca

Browse files
authored
Discard changes to lib/node_modules/@stdlib/blas/ext/base/ndarray/slast-index-of/lib/main.js
1 parent f894a17 commit 28ed5ca

File tree

1 file changed

+16
-5
lines changed
  • lib/node_modules/@stdlib/blas/ext/base/ndarray/slast-index-of/lib

1 file changed

+16
-5
lines changed

lib/node_modules/@stdlib/blas/ext/base/ndarray/slast-index-of/lib/main.js

Lines changed: 16 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -41,14 +41,14 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
4141
* var ndarray = require( '@stdlib/ndarray/base/ctor' );
4242
* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' );
4343
*
44-
* var xbuf = new Float32Array( [ 1.0, 2.0, 4.0, 2.0 ] );
44+
* var xbuf = new Float32Array( [ 1.0, 3.0, 4.0, 2.0 ] );
4545
* var x = new ndarray( 'float32', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
4646
*
4747
* var searchElement = scalar2ndarray( 2.0, {
4848
* 'dtype': 'float32'
4949
* });
5050
*
51-
* var fromIndex = scalar2ndarray( 3, {
51+
* var fromIndex = scalar2ndarray( 0, {
5252
* 'dtype': 'generic'
5353
* });
5454
*
@@ -58,6 +58,9 @@ var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' );
5858
function slastIndexOf( arrays ) {
5959
var searchElement;
6060
var fromIndex;
61+
var stride;
62+
var offset;
63+
var idx;
6164
var N;
6265
var x;
6366

@@ -69,12 +72,20 @@ function slastIndexOf( arrays ) {
6972
if ( fromIndex < 0 ) {
7073
fromIndex += N;
7174
if ( fromIndex < 0 ) {
72-
return -1;
75+
fromIndex = 0;
7376
}
7477
} else if ( fromIndex >= N ) {
75-
fromIndex = N - 1;
78+
return -1;
7679
}
77-
return strided( fromIndex+1, searchElement, getData( x ), getStride( x, 0 ), getOffset( x ) ); // eslint-disable-line max-len
80+
N -= fromIndex;
81+
stride = getStride( x, 0 );
82+
offset = getOffset( x ) + ( stride*fromIndex );
83+
84+
idx = strided( N, searchElement, getData( x ), stride, offset );
85+
if ( idx >= 0 ) {
86+
idx += fromIndex;
87+
}
88+
return idx;
7889
}
7990

8091

0 commit comments

Comments
 (0)