Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 6 additions & 26 deletions lib/node_modules/@stdlib/blas/ext/index-of/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -43,10 +43,7 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

// Perform operation:
var out = indexOf( x, 2.0 );
// returns <ndarray>

var idx = out.get();
// returns 1
// returns <ndarray>[ 1 ]
```

The function has the following parameters:
Expand All @@ -73,10 +70,7 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );

// Perform operation:
var out = indexOf( x, 10.0 );
// returns <ndarray>

var idx = out.get();
// returns -1
// returns <ndarray>[ -1 ]
```

By default, the function begins searching from the first element along the reduction dimension. To begin searching from a different index, provide a `fromIndex` argument.
Expand All @@ -90,34 +84,26 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 6.0 ] );

// Perform operation:
var out = indexOf( x, 2.0, 2 );
// returns <ndarray>

var idx = out.get();
// returns 4
// returns <ndarray>[ 4 ]
```

By default, the function performs the operation over elements in the last dimension. To perform the operation over a different dimension, provide a `dim` option.

```javascript
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var array = require( '@stdlib/ndarray/array' );

var x = array( [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ] );

var out = indexOf( x, -3.0, {
'dim': 0
});
// returns <ndarray>

var idx = ndarray2array( out );
// returns [ 1, -1 ]
// returns <ndarray>[ 1, -1 ]
```

By default, the function excludes reduced dimensions from the output [ndarray][@stdlib/ndarray/ctor]. To include the reduced dimensions as singleton dimensions, set the `keepdims` option to `true`.

```javascript
var array = require( '@stdlib/ndarray/array' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );

var x = array( [ [ -1.0, 2.0 ], [ -3.0, 4.0 ] ] );

Expand All @@ -127,10 +113,7 @@ var opts = {
};

var out = indexOf( x, -3.0, opts );
// returns <ndarray>

var idx = ndarray2array( out );
// returns [ [ 1, -1 ] ]
// returns <ndarray>[ [ 1, -1 ] ]
```

By default, the function returns an [ndarray][@stdlib/ndarray/ctor] having a [data type][@stdlib/ndarray/dtypes] determined by the function's output data type [policy][@stdlib/ndarray/output-dtype-policies]. To override the default behavior, set the `dtype` option.
Expand Down Expand Up @@ -164,10 +147,7 @@ var y = zeros( [], {
});

var out = indexOf.assign( x, 3.0, y );
// returns <ndarray>

var idx = out.get();
// returns 2
// returns <ndarray>[ 2 ]

var bool = ( out === y );
// returns true
Expand Down
9 changes: 3 additions & 6 deletions lib/node_modules/@stdlib/blas/ext/index-of/docs/repl.txt
Original file line number Diff line number Diff line change
Expand Up @@ -59,9 +59,8 @@
Examples
--------
> var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] );
> var y = {{alias}}( x, 2.0 );
> var v = y.get()
1
> var y = {{alias}}( x, 2.0 )
<ndarray>[ 1 ]


{{alias}}.assign( x, searchElement[, fromIndex], out[, options] )
Expand Down Expand Up @@ -122,11 +121,9 @@
> var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] );
> var out = {{alias:@stdlib/ndarray/zeros}}( [], { 'dtype': 'int32' } );
> var y = {{alias}}.assign( x, 2.0, out )
<ndarray>
<ndarray>[ 1 ]
> var bool = ( out === y )
true
> var v = out.get()
1

See Also
--------
30 changes: 6 additions & 24 deletions lib/node_modules/@stdlib/blas/ext/index-of/docs/types/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -95,10 +95,7 @@ interface IndexOf {
* var x = array( [ -1.0, 2.0, -3.0 ] );
*
* var y = indexOf( x, 2.0 );
* // returns <ndarray>
*
* var idx = y.get();
* // returns 1
* // returns <ndarray>[ 1 ]
*/
<T = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, options?: Options ): OutputArray;

Expand All @@ -122,10 +119,7 @@ interface IndexOf {
* var x = array( [ -1.0, 2.0, -3.0, 2.0, -5.0, 6.0 ] );
*
* var y = indexOf( x, 2.0, 2 );
* // returns <ndarray>
*
* var idx = y.get();
* // returns 3
* // returns <ndarray>[ 3 ]
*/
<T = unknown>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex, options?: Options ): OutputArray;

Expand Down Expand Up @@ -153,13 +147,10 @@ interface IndexOf {
* } );
*
* var out = indexOf.assign( x, 2.0, y );
* // returns <ndarray>
* // returns <ndarray>[ 1 ]
*
* var bool = ( out === y );
* // returns true
*
* var idx = out.get();
* // returns 1
*/
assign<T = unknown, U extends OutputArray = OutputArray>( x: InputArray<T>, searchElement: SearchElement<T>, out: U, options?: BaseOptions ): U;

Expand Down Expand Up @@ -188,13 +179,10 @@ interface IndexOf {
* } );
*
* var out = indexOf.assign( x, 2.0, 2, y );
* // returns <ndarray>
* // returns <ndarray>[ 3 ]
*
* var bool = ( out === y );
* // returns true
*
* var idx = out.get();
* // returns 3
*/
assign<T = unknown, U extends OutputArray = OutputArray>( x: InputArray<T>, searchElement: SearchElement<T>, fromIndex: FromIndex, out: U, options?: BaseOptions ): U;
}
Expand All @@ -219,10 +207,7 @@ interface IndexOf {
* var x = array( [ -1.0, 2.0, -3.0 ] );
*
* var y = indexOf( x, 2.0, 0 );
* // returns <ndarray>
*
* var idx = y.get();
* // returns 1
* // returns <ndarray>[ 1 ]
*
* @example
* var zeros = require( '@stdlib/ndarray/zeros' );
Expand All @@ -234,13 +219,10 @@ interface IndexOf {
* } );
*
* var out = indexOf.assign( x, 2.0, 2, y );
* // returns <ndarray>
* // returns <ndarray>[ 3 ]
*
* var bool = ( out === y );
* // returns true
*
* var idx = out.get();
* // returns 3
*/
declare const indexOf: IndexOf;

Expand Down
6 changes: 1 addition & 5 deletions lib/node_modules/@stdlib/blas/ext/index-of/lib/assign.js
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,6 @@
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var zeros = require( '@stdlib/ndarray/zeros' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
*
* // Create data buffers:
Expand All @@ -89,13 +88,10 @@
*
* // Perform operation:
* var out = assign( x, -5.0, y );
* // returns <ndarray>
* // returns <ndarray>[ -1, 1 ]
*
* var bool = ( out === y );
* // returns true
*
* var arr = ndarray2array( out );
* // returns [ -1, 1 ]
*/
function assign( x, searchElement, fromIndex, out ) {
var hasOptions;
Expand Down Expand Up @@ -211,7 +207,7 @@
if ( isndarrayLike( searchElement ) ) {
v = maybeBroadcastArray( searchElement, sh );
} else {
v = broadcastScalar( searchElement, dt, sh, ord ); // WARNING: potential for undesired value casting (e.g., if `searchElement` is `null` and cast to `float64`, the broadcasted scalar will be `0`, not `null`!)

Check warning on line 210 in lib/node_modules/@stdlib/blas/ext/index-of/lib/assign.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'warning' comment: 'WARNING: potential for undesired value...'
}
// Broadcast the `fromIndex` to match the shape of the non-reduced dimensions...
if ( iflg ) {
Expand Down
5 changes: 1 addition & 4 deletions lib/node_modules/@stdlib/blas/ext/index-of/lib/base.js
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@
'float64',
'float32'

// FIXME: add specialized support for `cindexOf` and `zindexOf` once the corresponding packages are implemented

Check warning on line 45 in lib/node_modules/@stdlib/blas/ext/index-of/lib/base.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'fixme' comment: 'FIXME: add specialized support for...'
],
'fcns': [
dindexOf,
Expand Down Expand Up @@ -107,10 +107,7 @@
*
* // Perform operation:
* var out = indexOf( x, searchElement, fromIndex );
* // returns <ndarray>
*
* var idx = out.get();
* // returns 3
* // returns <ndarray>[ 4 ]
*/
var indexOf = factory( table, [ idtypes0, idtypes1, idtypes2 ], odtypes, policies ); // eslint-disable-line max-len

Expand Down
6 changes: 1 addition & 5 deletions lib/node_modules/@stdlib/blas/ext/index-of/lib/index.js
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,6 @@
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
* var indexOf = require( '@stdlib/blas/ext/index-of' );
*
Expand All @@ -46,10 +45,7 @@
*
* // Perform operation:
* var out = indexOf( x, -5.0 );
* // returns <ndarray>
*
* var arr = ndarray2array( out );
* // returns [ -1, 1 ]
* // returns <ndarray>[ -1, 1 ]
*/

// MODULES //
Expand Down
6 changes: 1 addition & 5 deletions lib/node_modules/@stdlib/blas/ext/index-of/lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,7 +63,6 @@
*
* @example
* var Float64Array = require( '@stdlib/array/float64' );
* var ndarray2array = require( '@stdlib/ndarray/to-array' );
* var ndarray = require( '@stdlib/ndarray/ctor' );
*
* // Create a data buffer:
Expand All @@ -83,10 +82,7 @@
*
* // Perform operation:
* var out = indexOf( x, -5.0 );
* // returns <ndarray>
*
* var arr = ndarray2array( out );
* // returns [ -1, 1 ]
* // returns <ndarray>[ -1, 1 ]
*/
function indexOf( x, searchElement, fromIndex ) {
var hasOptions;
Expand Down Expand Up @@ -187,7 +183,7 @@
if ( isndarrayLike( searchElement ) ) {
v = maybeBroadcastArray( searchElement, sh );
} else {
v = broadcastScalar( searchElement, dt, sh, ord ); // WARNING: potential for undesired value casting (e.g., if `searchElement` is `null` and cast to `float64`, the broadcasted scalar will be `0`, not `null`!)

Check warning on line 186 in lib/node_modules/@stdlib/blas/ext/index-of/lib/main.js

View workflow job for this annotation

GitHub Actions / Lint Changed Files

Unexpected 'warning' comment: 'WARNING: potential for undesired value...'
}
// Broadcast the `fromIndex` to match the shape of the non-reduced dimensions...
if ( iflg ) {
Expand Down