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
27 changes: 25 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/find-last-index/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@ limitations under the License.
var findLastIndex = require( '@stdlib/blas/ext/find-last-index' );
```

#### findLastIndex( x\[, options], clbk\[, thisArg] )
#### findLastIndex( x\[, fromIndex]\[, options], clbk\[, thisArg] )

Returns the index of the last element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function.

Expand All @@ -56,6 +56,7 @@ var idx = out.get();
The function has the following parameters:

- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have at least one dimension.
- **fromIndex**: index from which to begin searching (_optional_). May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] having an integer index or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, a provided [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. If provided a negative integer, the index at which to begin searching along a dimension is determined by counting backward from the last element (where `-1` refers to the last element). Default: `-1`.
- **options**: function options (_optional_).
- **clbk**: callback function.
- **thisArg**: callback execution context (_optional_).
Expand Down Expand Up @@ -120,6 +121,27 @@ var idx = out.get();
// returns -1
```

By default, the function begins searching from the last element along the operation dimension. To begin searching from a different index, provide a `fromIndex` argument.

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

function isEven( v ) {
return v % 2.0 === 0.0;
}

// Create an input ndarray:
var x = array( [ 2.0, 1.0, 3.0, 4.0, 5.0, 6.0 ] );
// returns <ndarray>

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

var idx = out.get();
// returns 0
```

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
Expand Down Expand Up @@ -190,7 +212,7 @@ var dt = dtype( idx );
// returns 'generic'
```

#### findLastIndex.assign( x, out\[, options], clbk\[, thisArg] )
#### findLastIndex.assign( x\[, fromIndex], out\[, options], clbk\[, thisArg] )

Returns the index of the last element along an [ndarray][@stdlib/ndarray/ctor] dimension which passes a test implemented by a predicate function and assigns results to a provided output [ndarray][@stdlib/ndarray/ctor].

Expand Down Expand Up @@ -220,6 +242,7 @@ var bool = ( out === y );
The method has the following parameters:

- **x**: input [ndarray][@stdlib/ndarray/ctor]. Must have at least one dimension.
- **fromIndex**: index from which to begin searching (_optional_). May be either a scalar value or an [ndarray][@stdlib/ndarray/ctor] having an integer index or "generic" [data type][@stdlib/ndarray/dtypes]. If provided an [ndarray][@stdlib/ndarray/ctor], the value must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the non-reduced dimensions of the input [ndarray][@stdlib/ndarray/ctor]. For example, given the input shape `[2, 3, 4]` and `options.dim=0`, a provided [ndarray][@stdlib/ndarray/ctor] must have a shape which is [broadcast-compatible][@stdlib/ndarray/base/broadcast-shapes] with the shape `[3, 4]`. If provided a negative integer, the index at which to begin searching along a dimension is determined by counting backward from the last element (where `-1` refers to the last element). Default: `-1`.
- **out**: output [ndarray][@stdlib/ndarray/ctor].
- **options**: function options (_optional_).
- **clbk**: callback function.
Expand Down
26 changes: 24 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/find-last-index/docs/repl.txt
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@

{{alias}}( x[, options], clbk[, thisArg] )
{{alias}}( x[, fromIndex][, options], clbk[, thisArg] )
Returns the index of the last element along an ndarray dimension which
passes a test implemented by a predicate function.

Expand All @@ -20,6 +20,17 @@
x: ndarray
Input array. Must at least have one dimension.

fromIndex: ndarray|integer (optional)
Index from which to begin searching. May be either a scalar value or an
ndarray having an integer or "generic" data type. If provided an
ndarray, the value must have a shape which is broadcast compatible with
the non-reduced dimensions of the input ndarray. For example, given the
input shape `[2, 3, 4]` and `options.dim=0`, a provided ndarray must
have a shape which is broadcast-compatible with the shape `[3, 4]`. If
provided a negative integer, the index at which to begin searching along
a dimension is determined by counting backward from the last element
(where -1 refers to the last element). Default: -1.

options: Object (optional)
Function options.

Expand Down Expand Up @@ -56,7 +67,7 @@
3


{{alias}}.assign( x, out[, options], clbk[, thisArg] )
{{alias}}.assign( x[, fromIndex], out[, options], clbk[, thisArg] )
Returns the index of the last element along an ndarray dimension which
passes a test implemented by a predicate function and assigns results to a
provided output ndarray.
Expand All @@ -78,6 +89,17 @@
x: ndarray
Input array. Must at least have one dimension.

fromIndex: ndarray|integer (optional)
Index from which to begin searching. May be either a scalar value or an
ndarray having an integer or "generic" data type. If provided an
ndarray, the value must have a shape which is broadcast compatible with
the non-reduced dimensions of the input ndarray. For example, given the
input shape `[2, 3, 4]` and `options.dim=0`, a provided ndarray must
have a shape which is broadcast-compatible with the shape `[3, 4]`. If
provided a negative integer, the index at which to begin searching along
a dimension is determined by counting backward from the last element
(where -1 refers to the last element). Default: -1.

out: ndarray
Output array.

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -27,6 +27,11 @@ import { IntegerIndexAndGenericDataType as DataType, typedndarray } from '@stdli
*/
type InputArray<T> = typedndarray<T>;

/**
* From index.
*/
type FromIndex = typedndarray<number> | number;

/**
* Output array.
*/
Expand Down Expand Up @@ -138,6 +143,36 @@ interface FindLastIndex {
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function.
*
* ## Notes
*
* - If no element along an ndarray dimension passes a test implemented by the predicate function, the corresponding element in the returned ndarray is `-1`.
*
* @param x - input ndarray
* @param fromIndex - index from which to begin searching
* @param clbk - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var array = require( '@stdlib/ndarray/array' );
*
* function clbk( value ) {
* return value % 2.0 === 0.0;
* }
*
* var x = array( [ -1.0, 2.0, -3.0, 4.0 ] );
*
* var y = findLastIndex( x, 2, clbk );
* // returns <ndarray>
*
* var v = y.get();
* // returns 1
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, fromIndex: FromIndex, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function.
*
Expand Down Expand Up @@ -166,7 +201,38 @@ interface FindLastIndex {
* var v = y.get();
* // returns 1
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, options: Options, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray; // eslint-disable-line @typescript-eslint/unified-signatures

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function.
*
* ## Notes
*
* - If no element along an ndarray dimension passes a test implemented by the predicate function, the corresponding element in the returned ndarray is `-1`.
*
* @param x - input ndarray
* @param fromIndex - index from which to begin searching
* @param options - function options
* @param clbk - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var array = require( '@stdlib/ndarray/array' );
*
* function clbk( value ) {
* return value % 2.0 === 0.0;
* }
*
* var x = array( [ -1.0, 2.0, -3.0, 4.0 ] );
*
* var y = findLastIndex( x, 2, {}, clbk );
* // returns <ndarray>
*
* var v = y.get();
* // returns 1
*/
<T = unknown, U extends InputArray<T> = InputArray<T>, ThisArg = unknown>( x: U, fromIndex: FromIndex, options: Options, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): OutputArray;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
Expand Down Expand Up @@ -203,6 +269,42 @@ interface FindLastIndex {
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends OutputArray = OutputArray, ThisArg = unknown>( x: U, out: V, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
*
* ## Notes
*
* - If no element along an ndarray dimension passes a test implemented by the predicate function, the corresponding element in the returned ndarray is `-1`.
*
* @param x - input ndarray
* @param fromIndex - index from which to begin searching
* @param out - output ndarray
* @param clbk - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var array = require( '@stdlib/ndarray/array' );
* var zeros = require( '@stdlib/ndarray/zeros' );
*
* function clbk( value ) {
* return value % 2.0 === 0.0;
* }
*
* var x = array( [ -1.0, 2.0, -3.0, 4.0 ] );
* var y = zeros( [] );
*
* var out = findLastIndex.assign( x, 2, y, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 1
*
* var bool = ( out === y );
* // returns true
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends OutputArray = OutputArray, ThisArg = unknown>( x: U, fromIndex: FromIndex, out: V, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
*
Expand Down Expand Up @@ -238,6 +340,43 @@ interface FindLastIndex {
* // returns true
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends OutputArray = OutputArray, ThisArg = unknown>( x: U, out: V, options: BaseOptions, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;

/**
* Returns the index of the last element along an ndarray dimension which passes a test implemented by a predicate function and assigns results to a provided output ndarray.
*
* ## Notes
*
* - If no element along an ndarray dimension passes a test implemented by the predicate function, the corresponding element in the returned ndarray is `-1`.
*
* @param x - input ndarray
* @param fromIndex - index from which to begin searching
* @param out - output ndarray
* @param options - function options
* @param clbk - predicate function
* @param thisArg - predicate function execution context
* @returns output ndarray
*
* @example
* var array = require( '@stdlib/ndarray/array' );
* var zeros = require( '@stdlib/ndarray/zeros' );
*
* function clbk( value ) {
* return value % 2.0 === 0.0;
* }
*
* var x = array( [ -1.0, 2.0, -3.0, 4.0 ] );
* var y = zeros( [] );
*
* var out = findLastIndex.assign( x, 2, y, {}, clbk );
* // returns <ndarray>
*
* var v = out.get();
* // returns 1
*
* var bool = ( out === y );
* // returns true
*/
assign<T = unknown, U extends InputArray<T> = InputArray<T>, V extends OutputArray = OutputArray, ThisArg = unknown>( x: U, fromIndex: FromIndex, out: V, options: BaseOptions, clbk: Predicate<T, U, ThisArg>, thisArg?: ThisParameterType<Predicate<T, U, ThisArg>> ): V;
}

/**
Expand All @@ -248,6 +387,7 @@ interface FindLastIndex {
* - If no element along an ndarray dimension passes a test implemented by the predicate function, the corresponding element in the returned ndarray is `-1`.
*
* @param x - input ndarray
* @param fromIndex - index from which to begin searching
* @param options - function options
* @param clbk - predicate function
* @param thisArg - predicate function execution context
Expand Down
Loading