About stdlib...
We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.
The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.
When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.
To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!
Return the first index of a search element in a one-dimensional double-precision floating-point ndarray.
import dindexOf from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-ndarray-dindex-of@deno/mod.js';Returns the first index of a specified search element in a one-dimensional double-precision floating-point ndarray.
import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@deno/mod.js';
import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-scalar@deno/mod.js';
import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@deno/mod.js';
var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
var searchElement = scalar2ndarray( 2.0, {
'dtype': 'float64'
});
var fromIndex = scalar2ndarray( 0, {
'dtype': 'generic'
});
var idx = dindexOf( [ x, searchElement, fromIndex ] );
// returns 3The function has the following parameters:
-
arrays: array-like object containing the following ndarrays:
- a one-dimensional input ndarray.
- a zero-dimensional ndarray containing the search element.
- a zero-dimensional ndarray containing the index from which to begin searching.
If the function is unable to find a search element, the function returns -1.
import Float64Array from 'https://cdn.jsdelivr.net/gh/stdlib-js/array-float64@deno/mod.js';
import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-scalar@deno/mod.js';
import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@deno/mod.js';
var xbuf = new Float64Array( [ 1.0, 3.0, 4.0, 2.0 ] );
var x = new ndarray( 'float64', xbuf, [ 4 ], [ 1 ], 0, 'row-major' );
var searchElement = scalar2ndarray( 10.0, {
'dtype': 'float64'
});
var fromIndex = scalar2ndarray( 0, {
'dtype': 'generic'
});
var idx = dindexOf( [ x, searchElement, fromIndex ] );
// returns -1- If a specified starting search index is negative, the function resolves the starting search index by counting backward from the last element (where
-1refers to the last element).
import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-array-discrete-uniform@deno/mod.js';
import ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ctor@deno/mod.js';
import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-scalar@deno/mod.js';
import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@deno/mod.js';
import ndarraylike2scalar from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-base-ndarraylike2scalar@deno/mod.js';
import dindexOf from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-ndarray-dindex-of@deno/mod.js';
var xbuf = discreteUniform( 10, -100, 100, {
'dtype': 'float64'
});
var x = new ndarray( 'float64', xbuf, [ xbuf.length ], [ 1 ], 0, 'row-major' );
console.log( ndarray2array( x ) );
var searchElement = scalar2ndarray( 80.0, {
'dtype': 'float64'
});
console.log( 'Search Element:', ndarraylike2scalar( searchElement ) );
var fromIndex = scalar2ndarray( 0, {
'dtype': 'generic'
});
console.log( 'From Index:', ndarraylike2scalar( fromIndex ) );
var idx = dindexOf( [ x, searchElement, fromIndex ] );
console.log( idx );This package is part of stdlib, a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
See LICENSE.
Copyright © 2016-2025. The Stdlib Authors.