You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: ext/last-index-of/README.md
+6-26Lines changed: 6 additions & 26 deletions
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -43,10 +43,7 @@ var x = array( [ 1.0, 2.0, 3.0, 2.0, 5.0, 6.0 ] );
43
43
44
44
// Perform operation:
45
45
var out =lastIndexOf( x, 2.0 );
46
-
// returns <ndarray>
47
-
48
-
var idx =out.get();
49
-
// returns 3
46
+
// returns <ndarray>[ 3 ]
50
47
```
51
48
52
49
The function has the following parameters:
@@ -73,10 +70,7 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
73
70
74
71
// Perform operation:
75
72
var out =lastIndexOf( x, 10.0 );
76
-
// returns <ndarray>
77
-
78
-
var idx =out.get();
79
-
// returns -1
73
+
// returns <ndarray>[ -1 ]
80
74
```
81
75
82
76
By default, the function begins searching from the last element along the reduction dimension. To begin searching from a different index, provide a `fromIndex` argument.
@@ -90,34 +84,26 @@ var x = array( [ 1.0, 2.0, 3.0, 4.0, 2.0, 6.0 ] );
90
84
91
85
// Perform operation:
92
86
var out =lastIndexOf( x, 2.0, 3 );
93
-
// returns <ndarray>
94
-
95
-
var idx =out.get();
96
-
// returns 1
87
+
// returns <ndarray>[ 1 ]
97
88
```
98
89
99
90
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.
100
91
101
92
```javascript
102
-
var ndarray2array =require( '@stdlib/ndarray/to-array' );
103
93
var array =require( '@stdlib/ndarray/array' );
104
94
105
95
var x =array( [ [ -3.0, 2.0 ], [ -3.0, 4.0 ] ] );
106
96
107
97
var out =lastIndexOf( x, -3.0, {
108
98
'dim':0
109
99
});
110
-
// returns <ndarray>
111
-
112
-
var idx =ndarray2array( out );
113
-
// returns [ 1, -1 ]
100
+
// returns <ndarray>[ 1, -1 ]
114
101
```
115
102
116
103
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`.
117
104
118
105
```javascript
119
106
var array =require( '@stdlib/ndarray/array' );
120
-
var ndarray2array =require( '@stdlib/ndarray/to-array' );
121
107
122
108
var x =array( [ [ -3.0, 2.0 ], [ -3.0, 4.0 ] ] );
123
109
@@ -127,10 +113,7 @@ var opts = {
127
113
};
128
114
129
115
var out =lastIndexOf( x, -3.0, opts );
130
-
// returns <ndarray>
131
-
132
-
var idx =ndarray2array( out );
133
-
// returns [ [ 1, -1 ] ]
116
+
// returns <ndarray>[ [ 1, -1 ] ]
134
117
```
135
118
136
119
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.
0 commit comments