diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/README.md b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/README.md index 5d18d70d09bd..56fd65ecc1a9 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/README.md +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/README.md @@ -42,11 +42,16 @@ Returns the index of the last element in a one-dimensional double-precision floa ```javascript var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Vector( [ 0.0, 0.0, 3.0, 0.0 ] ); -var idx = dlastIndexEqual( [ x, y ] ); +var fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' +}); + +var idx = dlastIndexEqual( [ x, y, fromIndex ] ); // returns 2 ``` @@ -56,16 +61,22 @@ The function has the following parameters: - first one-dimensional input ndarray. - second one-dimensional input ndarray. + - a zero-dimensional ndarray containing the index from which to begin searching. If the function is unable to find matching elements, the function returns `-1`. ```javascript var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0 ] ); var y = new Float64Vector( [ 5.0, 6.0, 7.0, 8.0 ] ); -var idx = dlastIndexEqual( [ x, y ] ); +var fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' +}); + +var idx = dlastIndexEqual( [ x, y, fromIndex ] ); // returns -1 ``` @@ -77,6 +88,7 @@ var idx = dlastIndexEqual( [ x, y ] ); ## Notes +- 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). - When comparing elements, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. @@ -91,7 +103,9 @@ var idx = dlastIndexEqual( [ x, y ] ); ```javascript var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); var dlastIndexEqual = require( '@stdlib/blas/ext/base/ndarray/dlast-index-equal' ); var opts = { @@ -103,7 +117,12 @@ console.log( ndarray2array( x ) ); var y = discreteUniform( [ 10 ], 0, 10, opts ); console.log( ndarray2array( y ) ); -var idx = dlastIndexEqual( [ x, y ] ); +var fromIndex = scalar2ndarray( 9, { + 'dtype': 'generic' +}); +console.log( 'From Index:', ndarraylike2scalar( fromIndex ) ); + +var idx = dlastIndexEqual( [ x, y, fromIndex ] ); console.log( idx ); ``` diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/benchmark/benchmark.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/benchmark/benchmark.js index 67e42aa82841..ffe3a51bc9f8 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/benchmark/benchmark.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/benchmark/benchmark.js @@ -23,9 +23,9 @@ var bench = require( '@stdlib/bench' ); var isInteger = require( '@stdlib/assert/is-integer' ).isPrimitive; var pow = require( '@stdlib/math/base/special/pow' ); -var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); -var ones = require( '@stdlib/array/ones' ); -var zeros = require( '@stdlib/array/zeros' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); +var ones = require( '@stdlib/ndarray/ones' ); +var zeros = require( '@stdlib/ndarray/zeros' ); var format = require( '@stdlib/string/format' ); var pkg = require( './../package.json' ).name; var dlastIndexEqual = require( './../lib' ); @@ -48,8 +48,15 @@ var options = { * @returns {Function} benchmark function */ function createBenchmark( len ) { - var x = new Float64Vector( ones( len, options.dtype ) ); - var y = new Float64Vector( zeros( len, options.dtype ) ); + var fromIndex; + var x; + var y; + + x = ones( [ len ], options ); + y = zeros( [ len ], options ); + fromIndex = scalar2ndarray( len - 1, { + 'dtype': 'generic' + }); return benchmark; /** @@ -64,7 +71,7 @@ function createBenchmark( len ) { b.tic(); for ( i = 0; i < b.iterations; i++ ) { - out = dlastIndexEqual( [ x, y ] ); + out = dlastIndexEqual( [ x, y, fromIndex ] ); if ( out !== out ) { b.fail( 'should return an integer' ); } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/repl.txt b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/repl.txt index daccf8d51d51..9c3820bb7885 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/repl.txt +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/repl.txt @@ -4,6 +4,10 @@ precision floating-point ndarray equal to a corresponding element in another one-dimensional double-precision floating-point ndarray. + 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). + When comparing elements, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. @@ -15,6 +19,8 @@ - first one-dimensional input ndarray. - second one-dimensional input ndarray. + - a zero-dimensional ndarray containing the index from which to begin + searching. Returns ------- @@ -25,7 +31,8 @@ -------- > var x = new {{alias:@stdlib/ndarray/vector/float64}}( [ 1.0, 2.0, 3.0, 4.0 ] ); > var y = new {{alias:@stdlib/ndarray/vector/float64}}( [ 0.0, 0.0, 3.0, 0.0 ] ); - > {{alias}}( [ x, y ] ) + > var i = {{alias:@stdlib/ndarray/from-scalar}}( 3, { 'dtype': 'generic' } ); + > {{alias}}( [ x, y, i ] ) 2 See Also diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/index.d.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/index.d.ts index 16f43af9e401..0df26c02e9fd 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/index.d.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/index.d.ts @@ -20,7 +20,7 @@ /// -import { float64ndarray } from '@stdlib/types/ndarray'; +import { float64ndarray, typedndarray } from '@stdlib/types/ndarray'; /** * Returns the index of the last element in a one-dimensional double-precision floating-point ndarray equal to a corresponding element in another one-dimensional double-precision floating-point ndarray. @@ -31,6 +31,7 @@ import { float64ndarray } from '@stdlib/types/ndarray'; * * - first one-dimensional input ndarray. * - second one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the index from which to begin searching. * * - When comparing elements, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. * @@ -39,14 +40,19 @@ import { float64ndarray } from '@stdlib/types/ndarray'; * * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * * var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Vector( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dlastIndexEqual( [ x, y ] ); +* var fromIndex = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* var idx = dlastIndexEqual( [ x, y, fromIndex ] ); * // returns 2 */ -declare function dlastIndexEqual( arrays: [ float64ndarray, float64ndarray ] ): number; +declare function dlastIndexEqual( arrays: [ float64ndarray, float64ndarray, typedndarray ] ): number; // EXPORTS // diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/test.ts b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/test.ts index 3acff3384626..84aa3fd7ed58 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/test.ts +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/docs/types/test.ts @@ -19,6 +19,7 @@ /* eslint-disable space-in-parens */ import zeros = require( '@stdlib/ndarray/zeros' ); +import scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); import dlastIndexEqual = require( './index' ); @@ -32,8 +33,11 @@ import dlastIndexEqual = require( './index' ); const y = zeros( [ 10 ], { 'dtype': 'float64' }); + const fromIndex = scalar2ndarray( 0, { + 'dtype': 'generic' + }); - dlastIndexEqual( [ x, y ] ); // $ExpectType number + dlastIndexEqual( [ x, y, fromIndex ] ); // $ExpectType number } // The compiler throws an error if the function is provided a first argument which is not an array of ndarrays... @@ -57,7 +61,10 @@ import dlastIndexEqual = require( './index' ); const y = zeros( [ 10 ], { 'dtype': 'float64' }); + const fromIndex = scalar2ndarray( 0, { + 'dtype': 'generic' + }); dlastIndexEqual(); // $ExpectError - dlastIndexEqual( [ x, y ], {} ); // $ExpectError + dlastIndexEqual( [ x, y, fromIndex ], {} ); // $ExpectError } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/examples/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/examples/index.js index 2ae2c228aeea..2f71ee0377e7 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/examples/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/examples/index.js @@ -19,7 +19,9 @@ 'use strict'; var discreteUniform = require( '@stdlib/random/discrete-uniform' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var ndarray2array = require( '@stdlib/ndarray/to-array' ); +var ndarraylike2scalar = require( '@stdlib/ndarray/ndarraylike2scalar' ); var dlastIndexEqual = require( './../lib' ); var opts = { @@ -31,5 +33,10 @@ console.log( ndarray2array( x ) ); var y = discreteUniform( [ 10 ], 0, 10, opts ); console.log( ndarray2array( y ) ); -var idx = dlastIndexEqual( [ x, y ] ); +var fromIndex = scalar2ndarray( 9, { + 'dtype': 'generic' +}); +console.log( 'From Index:', ndarraylike2scalar( fromIndex ) ); + +var idx = dlastIndexEqual( [ x, y, fromIndex ] ); console.log( idx ); diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/index.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/index.js index 75913d5c92ba..4b2e3aab2286 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/index.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/index.js @@ -25,12 +25,17 @@ * * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * var dlastIndexEqual = require( '@stdlib/blas/ext/base/ndarray/dlast-index-equal' ); * * var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Vector( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dlastIndexEqual( [ x, y ] ); +* var fromIndex = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* var idx = dlastIndexEqual( [ x, y, fromIndex ] ); * // returns 2 */ diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/main.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/main.js index f30003aea3f6..7b76e680c5dc 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/main.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/lib/main.js @@ -20,10 +20,12 @@ // MODULES // +var ndarraylike2scalar = require( '@stdlib/ndarray/base/ndarraylike2scalar' ); var numelDimension = require( '@stdlib/ndarray/base/numel-dimension' ); var getStride = require( '@stdlib/ndarray/base/stride' ); var getOffset = require( '@stdlib/ndarray/base/offset' ); var getData = require( '@stdlib/ndarray/base/data-buffer' ); +var clipIndex = require( '@stdlib/ndarray/base/clip-index' ); var strided = require( '@stdlib/blas/ext/base/dlast-index-equal' ).ndarray; @@ -38,6 +40,7 @@ var strided = require( '@stdlib/blas/ext/base/dlast-index-equal' ).ndarray; * * - first one-dimensional input ndarray. * - second one-dimensional input ndarray. +* - a zero-dimensional ndarray containing the index from which to begin searching. * * - When comparing elements, the function checks for equality using the strict equality operator `===`. As a consequence, `NaN` values are considered distinct, and `-0` and `+0` are considered the same. * @@ -46,17 +49,34 @@ var strided = require( '@stdlib/blas/ext/base/dlast-index-equal' ).ndarray; * * @example * var Float64Vector = require( '@stdlib/ndarray/vector/float64' ); +* var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); * * var x = new Float64Vector( [ 1.0, 2.0, 3.0, 4.0 ] ); * var y = new Float64Vector( [ 0.0, 0.0, 3.0, 0.0 ] ); * -* var idx = dlastIndexEqual( [ x, y ] ); +* var fromIndex = scalar2ndarray( 3, { +* 'dtype': 'generic' +* }); +* +* var idx = dlastIndexEqual( [ x, y, fromIndex ] ); * // returns 2 */ function dlastIndexEqual( arrays ) { - var x = arrays[ 0 ]; - var y = arrays[ 1 ]; - return strided( numelDimension( x, 0 ), getData( x ), getStride( x, 0 ), getOffset( x ), getData( y ), getStride( y, 0 ), getOffset( y ) ); // eslint-disable-line max-len + var fromIndex; + var N; + var x; + var y; + + x = arrays[ 0 ]; + y = arrays[ 1 ]; + fromIndex = ndarraylike2scalar( arrays[ 2 ] ); + + N = numelDimension( x, 0 ); + fromIndex = clipIndex( fromIndex, N ); + if ( fromIndex >= N ) { + fromIndex = N - 1; + } + return strided( fromIndex+1, getData( x ), getStride( x, 0 ), getOffset( x ), getData( y ), getStride( y, 0 ), getOffset( y ) ); // eslint-disable-line max-len } diff --git a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/test/test.js b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/test/test.js index be1c0ae0eca9..d1a5261eb754 100644 --- a/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/test/test.js +++ b/lib/node_modules/@stdlib/blas/ext/base/ndarray/dlast-index-equal/test/test.js @@ -23,6 +23,7 @@ var tape = require( 'tape' ); var ndarray = require( '@stdlib/ndarray/base/ctor' ); var Float64Array = require( '@stdlib/array/float64' ); +var scalar2ndarray = require( '@stdlib/ndarray/from-scalar' ); var dlastIndexEqual = require( './../lib' ); @@ -52,56 +53,80 @@ tape( 'main export is a function', function test( t ) { }); tape( 'the function returns the index of the last element in a one-dimensional ndarray equal to a corresponding element in another one-dimensional ndarray', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + x = vector( new Float64Array( [ 1.0, 1.0, 2.0, 2.0, 3.0, 3.0 ] ), 6, 1, 0 ); y = vector( new Float64Array( [ 1.0, 0.0, 2.0, 0.0, 3.0, 0.0 ] ), 6, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, 4, 'returns expected value' ); x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0 ] ), 4, 1, 0 ); y = vector( new Float64Array( [ 0.0, 0.0, 3.0, 0.0 ] ), 4, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, 2, 'returns expected value' ); x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); y = vector( new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 6.0 ] ), 6, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + fromIndex = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, 5, 'returns expected value' ); x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); y = vector( new Float64Array( [ 0.0, 0.0, 0.0, 0.0, 0.0, 0.0 ] ), 6, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + fromIndex = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); tape( 'the function returns `-1` if unable to find matching elements', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); y = vector( new Float64Array( [ 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] ), 6, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); tape( 'the function supports one-dimensional ndarrays having non-unit strides', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' + }); + x = new Float64Array([ 1.0, // 0 2.0, @@ -123,17 +148,22 @@ tape( 'the function supports one-dimensional ndarrays having non-unit strides', 8.0 ]); - actual = dlastIndexEqual( [ vector( x, 4, 2, 0 ), vector( y, 4, 2, 0 ) ] ); + actual = dlastIndexEqual( [ vector( x, 4, 2, 0 ), vector( y, 4, 2, 0 ), fromIndex ] ); t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); tape( 'the function supports one-dimensional ndarrays having negative strides', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' + }); + x = new Float64Array([ 1.0, // 3 2.0, @@ -155,17 +185,22 @@ tape( 'the function supports one-dimensional ndarrays having negative strides', 8.0 ]); - actual = dlastIndexEqual( [ vector( x, 4, -2, 6 ), vector( y, 4, -2, 6 ) ] ); + actual = dlastIndexEqual( [ vector( x, 4, -2, 6 ), vector( y, 4, -2, 6 ), fromIndex ] ); t.strictEqual( actual, 2, 'returns expected value' ); t.end(); }); tape( 'the function supports one-dimensional ndarrays having non-zero offsets', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 3, { + 'dtype': 'generic' + }); + x = new Float64Array([ 0.0, 1.0, // 0 @@ -187,36 +222,156 @@ tape( 'the function supports one-dimensional ndarrays having non-zero offsets', 4.0 // 3 ]); - actual = dlastIndexEqual( [ vector( x, 4, 2, 1 ), vector( y, 4, 2, 1 ) ] ); + actual = dlastIndexEqual( [ vector( x, 4, 2, 1 ), vector( y, 4, 2, 1 ), fromIndex ] ); t.strictEqual( actual, 3, 'returns expected value' ); t.end(); }); tape( 'the function considers NaN values as distinct', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + x = vector( new Float64Array( [ NaN, NaN, NaN ] ), 3, 1, 0 ); y = vector( new Float64Array( [ NaN, NaN, NaN ] ), 3, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, -1, 'returns expected value' ); t.end(); }); tape( 'the function considers -0 and +0 as the same', function test( t ) { + var fromIndex; var actual; var x; var y; + fromIndex = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + x = vector( new Float64Array( [ 1.0, -0.0, 3.0 ] ), 3, 1, 0 ); y = vector( new Float64Array( [ 0.0, 0.0, 0.0 ] ), 3, 1, 0 ); - actual = dlastIndexEqual( [ x, y ] ); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); t.strictEqual( actual, 1, 'returns expected value' ); t.end(); }); + +tape( 'the function supports a nonnegative starting search index', function test( t ) { + var fromIndex; + var actual; + var x; + var y; + + x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); + y = vector( new Float64Array( [ 1.0, 2.0, 0.0, 4.0, 0.0, 6.0 ] ), 6, 1, 0 ); + + fromIndex = scalar2ndarray( 5, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 5, 'returns expected value' ); + + fromIndex = scalar2ndarray( 4, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 3, 'returns expected value' ); + + fromIndex = scalar2ndarray( 2, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 1, 'returns expected value' ); + + fromIndex = scalar2ndarray( 0, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function supports a negative starting search index', function test( t ) { + var fromIndex; + var actual; + var x; + var y; + + x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); + y = vector( new Float64Array( [ 1.0, 2.0, 0.0, 4.0, 0.0, 6.0 ] ), 6, 1, 0 ); + + fromIndex = scalar2ndarray( -1, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 5, 'returns expected value' ); + + fromIndex = scalar2ndarray( -2, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 3, 'returns expected value' ); + + fromIndex = scalar2ndarray( -3, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 3, 'returns expected value' ); + + fromIndex = scalar2ndarray( -5, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 1, 'returns expected value' ); + + fromIndex = scalar2ndarray( -6, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 0, 'returns expected value' ); + + fromIndex = scalar2ndarray( -7, { + 'dtype': 'generic' + }); + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 0, 'returns expected value' ); + + t.end(); +}); + +tape( 'the function clamps a starting search index which is greater than or equal to number of elements in the input ndarray', function test( t ) { + var fromIndex; + var actual; + var x; + var y; + + x = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); + y = vector( new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ), 6, 1, 0 ); + + fromIndex = scalar2ndarray( 6, { + 'dtype': 'generic' + }); + + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 5, 'returns expected value' ); + + fromIndex = scalar2ndarray( 7, { + 'dtype': 'generic' + }); + + actual = dlastIndexEqual( [ x, y, fromIndex ] ); + t.strictEqual( actual, 5, 'returns expected value' ); + + t.end(); +});