|
1 | 1 |
|
2 | 2 | {{alias}}( x, searchElement[, fromIndex][, options] ) |
3 | | - Returns the first index of a specified search element along one or more |
4 | | - ndarray dimensions. |
| 3 | + Returns the first index of a specified search element along an ndarray |
| 4 | + dimension. |
| 5 | + |
| 6 | + When searching for a search element, the function checks for equality using |
| 7 | + the strict equality operator `===`. As a consequence, `NaN` values are |
| 8 | + considered distinct, and `-0` and `+0` are considered the same. |
| 9 | + |
| 10 | + If unable to find a search element along an ndarray dimension, the |
| 11 | + corresponding element in the returned ndarray is `-1`. |
5 | 12 |
|
6 | 13 | Parameters |
7 | 14 | ---------- |
8 | 15 | x: ndarray |
9 | | - Input array. |
10 | | - |
11 | | - searchElement: ndarray|* |
12 | | - Element in an input ndarray for which to find an index. May be either a |
13 | | - scalar value or an ndarray having a data type same as the data type of |
14 | | - the input ndarray. If provided a scalar value, the value is cast to the |
15 | | - data type of the input ndarray. If provided an ndarray, the value must |
16 | | - have a shape which is broadcast compatible with the complement of the |
17 | | - shape defined by `options.dims`. For example, given the input shape |
18 | | - `[2, 3, 4]` and `options.dims=[0]`, the search element ndarray must have |
19 | | - a shape which is broadcast-compatible with the shape `[3, 4]`. Similarly |
20 | | - when performing the operation over all elements in a provided input |
21 | | - ndarray, a search element ndarray must be a zero-dimensional ndarray. |
| 16 | + Input array. Must have at least one dimension. |
| 17 | + |
| 18 | + searchElement: ndarray|any |
| 19 | + Search element. May be either a scalar value or an ndarray. If provided |
| 20 | + a scalar value, the value is cast to the data type of the input ndarray. |
| 21 | + If provided an ndarray, the value must have a shape which is broadcast |
| 22 | + compatible with the non-reduced dimensions of the input ndarray. For |
| 23 | + example, given the input shape `[2, 3, 4]` and `options.dim=0`, the |
| 24 | + search element ndarray must have a shape which is broadcast-compatible |
| 25 | + with the shape `[3, 4]`. |
22 | 26 |
|
23 | 27 | fromIndex: ndarray|integer (optional) |
24 | 28 | Index from which to begin searching. May be either a scalar value or an |
25 | | - ndarray having an `integer` or `generic` data type. If provided an |
26 | | - ndarray the value must have a shape which is broadcast compatible with |
27 | | - the complement of the shape defined by `options.dims`. For example, |
28 | | - given the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray |
29 | | - containing the index from which to begin searching must have a shape |
30 | | - which is broadcast-compatible with the shape `[3, 4]`. Similarly |
31 | | - when performing the operation over all elements in a provided input |
32 | | - ndarray, an ndarray containing the index from which to begin searching |
33 | | - must be a zero-dimensional ndarray. By default, the index |
34 | | - from which to begin searching is `0`. |
| 29 | + ndarray having an integer or "generic" data type. If provided an ndarray |
| 30 | + the value must have a shape which is broadcast compatible with the non- |
| 31 | + reduced dimensions of the input ndarray. For example, given the input |
| 32 | + shape `[2, 3, 4]` and `options.dim=0`, a provided ndarray must have a |
| 33 | + shape which is broadcast-compatible with the shape `[3, 4]`. Default: 0. |
35 | 34 |
|
36 | 35 | options: Object (optional) |
37 | 36 | Function options. |
38 | 37 |
|
39 | 38 | options.dtype: string (optional) |
40 | | - Output array data type. Must be an integer or generic data type. |
| 39 | + Output array data type. Must be an integer or "generic" data type. |
41 | 40 |
|
42 | | - options.dims: Array<integer> (optional) |
43 | | - List of dimensions over which to perform a reduction. If not provided, |
44 | | - the function performs a reduction over all elements in a provided input |
45 | | - ndarray. |
| 41 | + options.dim: integer (optional) |
| 42 | + Dimension over which to perform a reduction. If provided a negative |
| 43 | + integer, the dimension along which to perform the operation is |
| 44 | + determined by counting backward from the last dimension (where -1 refers |
| 45 | + to the last dimension). Default: -1. |
46 | 46 |
|
47 | 47 | options.keepdims: boolean (optional) |
48 | 48 | Boolean indicating whether the reduced dimensions should be included in |
|
58 | 58 | > var x = {{alias:@stdlib/ndarray/array}}( [ -1.0, 2.0, -3.0, -4.0 ] ); |
59 | 59 | > var y = {{alias}}( x, 2.0 ); |
60 | 60 | > var v = y.get() |
61 | | - 1.0 |
| 61 | + 1 |
62 | 62 |
|
63 | 63 |
|
64 | 64 | {{alias}}.assign( x, searchElement[, fromIndex], out[, options] ) |
65 | | - Returns the first index of a specified search element along one or more |
66 | | - ndarray dimensions and assigns results to a provided output ndarray. |
| 65 | + Returns the first index of a specified search element along an ndarray |
| 66 | + dimension and assigns results to a provided output ndarray. |
| 67 | + |
| 68 | + When searching for a search element, the function checks for equality using |
| 69 | + the strict equality operator `===`. As a consequence, `NaN` values are |
| 70 | + considered distinct, and `-0` and `+0` are considered the same. |
| 71 | + |
| 72 | + If unable to find a search element along an ndarray dimension, the |
| 73 | + corresponding element in the returned ndarray is `-1`. |
67 | 74 |
|
68 | 75 | Parameters |
69 | 76 | ---------- |
70 | 77 | x: ndarray |
71 | | - Input array. |
72 | | - |
73 | | - searchElement: ndarray|* |
74 | | - Element in an input ndarray for which to find an index. May be either a |
75 | | - scalar value or an ndarray having a data type same as the data type of |
76 | | - the input ndarray. If provided a scalar value, the value is cast to the |
77 | | - data type of the input ndarray. If provided an ndarray, the value must |
78 | | - have a shape which is broadcast compatible with the complement of the |
79 | | - shape defined by `options.dims`. For example, given the input shape |
80 | | - `[2, 3, 4]` and `options.dims=[0]`, the search element ndarray must have |
81 | | - a shape which is broadcast-compatible with the shape `[3, 4]`. Similarly |
82 | | - when performing the operation over all elements in a provided input |
83 | | - ndarray, a search element ndarray must be a zero-dimensional ndarray. |
| 78 | + Input array. Must have at least one dimension. |
| 79 | + |
| 80 | + searchElement: ndarray|any |
| 81 | + Search element. May be either a scalar value or an ndarray. If provided |
| 82 | + a scalar value, the value is cast to the data type of the input ndarray. |
| 83 | + If provided an ndarray, the value must have a shape which is broadcast |
| 84 | + compatible with the non-reduced dimensions of the input ndarray. For |
| 85 | + example, given the input shape `[2, 3, 4]` and `options.dim=0`, the |
| 86 | + search element ndarray must have a shape which is broadcast-compatible |
| 87 | + with the shape `[3, 4]`. |
84 | 88 |
|
85 | 89 | fromIndex: ndarray|integer (optional) |
86 | 90 | Index from which to begin searching. May be either a scalar value or an |
87 | | - ndarray having an `integer` or `generic` data type. If provided an |
88 | | - ndarray the value must have a shape which is broadcast compatible with |
89 | | - the complement of the shape defined by `options.dims`. For example, |
90 | | - given the input shape `[2, 3, 4]` and `options.dims=[0]`, an ndarray |
91 | | - containing the index from which to begin searching must have a shape |
92 | | - which is broadcast-compatible with the shape `[3, 4]`. Similarly |
93 | | - when performing the operation over all elements in a provided input |
94 | | - ndarray, an ndarray containing the index from which to begin searching |
95 | | - must be a zero-dimensional ndarray. By default, the value of the index |
96 | | - from which to begin searching is `0`. |
| 91 | + ndarray having an integer or "generic" data type. If provided an ndarray |
| 92 | + the value must have a shape which is broadcast compatible with the non- |
| 93 | + reduced dimensions of the input ndarray. For example, given the input |
| 94 | + shape `[2, 3, 4]` and `options.dim=0`, a provided ndarray must have a |
| 95 | + shape which is broadcast-compatible with the shape `[3, 4]`. Default: 0. |
97 | 96 |
|
98 | 97 | out: ndarray |
99 | 98 | Output array. |
100 | 99 |
|
101 | 100 | options: Object (optional) |
102 | 101 | Function options. |
103 | 102 |
|
104 | | - options.dims: Array<integer> (optional) |
105 | | - List of dimensions over which to perform a reduction. If not provided, |
106 | | - the function performs a reduction over all elements in a provided input |
107 | | - ndarray. |
| 103 | + options.dim: integer (optional) |
| 104 | + Dimension over which to perform a reduction. If provided a negative |
| 105 | + integer, the dimension along which to perform the operation is |
| 106 | + determined by counting backward from the last dimension (where -1 refers |
| 107 | + to the last dimension). Default: -1. |
108 | 108 |
|
109 | 109 | Returns |
110 | 110 | ------- |
|
120 | 120 | > var bool = ( out === y ) |
121 | 121 | true |
122 | 122 | > var v = out.get() |
123 | | - 1.0 |
| 123 | + 1 |
124 | 124 |
|
125 | 125 | See Also |
126 | 126 | -------- |
0 commit comments