@@ -51,7 +51,7 @@ var searchElement = scalar2ndarray( 1.0, {
5151});
5252
5353var fromIndex = scalar2ndarray ( 0 , {
54- ' dtype' : ' generic '
54+ ' dtype' : ' int32 '
5555});
5656
5757var idx = sindexOfNotEqual ( [ x, searchElement, fromIndex ] );
@@ -79,7 +79,7 @@ var searchElement = scalar2ndarray( 1.0, {
7979});
8080
8181var fromIndex = scalar2ndarray ( 0 , {
82- ' dtype' : ' generic '
82+ ' dtype' : ' int32 '
8383});
8484
8585var idx = sindexOfNotEqual ( [ x, searchElement, fromIndex ] );
@@ -125,7 +125,7 @@ var searchElement = scalar2ndarray( 0, opts );
125125console .log ( ' Search Element:' , ndarraylike2scalar ( searchElement ) );
126126
127127var fromIndex = scalar2ndarray ( 0 , {
128- ' dtype' : ' generic '
128+ ' dtype' : ' int32 '
129129});
130130console .log ( ' From Index:' , ndarraylike2scalar ( fromIndex ) );
131131
@@ -137,6 +137,196 @@ console.log( idx );
137137
138138<!-- /.examples -->
139139
140+ <!-- C interface documentation. -->
141+
142+ * * *
143+
144+ <section class =" c " >
145+
146+ ## C APIs
147+
148+ <!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
149+
150+ <section class =" intro " >
151+
152+ </section >
153+
154+ <!-- /.intro -->
155+
156+ <!-- C usage documentation. -->
157+
158+ <section class =" usage " >
159+
160+ ### Usage
161+
162+ ``` c
163+ #include " stdlib/blas/ext/base/ndarray/sindex_of_not_equal.h"
164+ ```
165+
166+ #### stdlib_blas_ext_sindex_of_not_equal( arrays )
167+
168+ Returns the first index of an element in a one-dimensional single-precision floating-point ndarray which is not equal to a specified search element.
169+
170+ ``` c
171+ #include " stdlib/ndarray/ctor.h"
172+ #include " stdlib/ndarray/dtypes.h"
173+ #include " stdlib/ndarray/index_modes.h"
174+ #include " stdlib/ndarray/orders.h"
175+ #include " stdlib/ndarray/base/bytes_per_element.h"
176+ #include " stdlib/blas/base/shared.h"
177+ #include < stdint.h>
178+
179+ // Create an input ndarray:
180+ const float data[] = { 1.0f, 1.0f, 3.0f };
181+ int64_t shape[ ] = { 3 };
182+ int64_t strides[ ] = { STDLIB_NDARRAY_FLOAT32_BYTES_PER_ELEMENT };
183+ int8_t submodes[ ] = { STDLIB_NDARRAY_INDEX_ERROR };
184+
185+ struct ndarray * x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t * )data, 1, shape, strides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes );
186+
187+ // Create zero-dimensional ndarrays containing the search element and the index from which to begin searching:
188+ const float sdata[ ] = { 1.0f };
189+ const int32_t fdata[ ] = { 0 };
190+ int64_t sstrides[ ] = { 0 };
191+
192+ struct ndarray * searchElement = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t * )sdata, 0, NULL, sstrides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes );
193+ struct ndarray * fromIndex = stdlib_ndarray_allocate( STDLIB_NDARRAY_INT32, (uint8_t * )fdata, 0, NULL, sstrides, 0, STDLIB_NDARRAY_ROW_MAJOR, STDLIB_NDARRAY_INDEX_ERROR, 1, submodes );
194+
195+ // Resolve the index:
196+ const struct ndarray * arrays[ ] = { x, searchElement, fromIndex };
197+ CBLAS_INT idx = stdlib_blas_ext_sindex_of_not_equal( arrays );
198+ // returns 2
199+
200+ // Free allocated memory:
201+ stdlib_ndarray_free ( x );
202+ stdlib_ndarray_free ( searchElement );
203+ stdlib_ndarray_free ( fromIndex );
204+ ```
205+
206+ The function accepts the following arguments:
207+
208+ - **arrays**: `[in] struct ndarray**` list containing the following ndarrays:
209+
210+ - a one-dimensional input ndarray.
211+ - a zero-dimensional ndarray containing the search element.
212+ - a zero-dimensional ndarray containing the index from which to begin searching.
213+
214+ ```c
215+ CBLAS_INT stdlib_blas_ext_sindex_of_not_equal( const struct ndarray *arrays[] );
216+ ```
217+
218+ </section >
219+
220+ <!-- /.usage -->
221+
222+ <!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
223+
224+ <section class =" notes " >
225+
226+ - The zero-dimensional ndarray containing the index from which to begin searching must have an ` int32 ` data type.
227+
228+ </section >
229+
230+ <!-- /.notes -->
231+
232+ <!-- C API usage examples. -->
233+
234+ <section class =" examples " >
235+
236+ ### Examples
237+
238+ ``` c
239+ #include " stdlib/blas/ext/base/ndarray/sindex_of_not_equal.h"
240+ #include " stdlib/ndarray/ctor.h"
241+ #include " stdlib/ndarray/dtypes.h"
242+ #include " stdlib/ndarray/index_modes.h"
243+ #include " stdlib/ndarray/orders.h"
244+ #include " stdlib/ndarray/base/bytes_per_element.h"
245+ #include " stdlib/blas/base/shared.h"
246+ #include < stdint.h>
247+ #include < stdlib.h>
248+ #include < stdio.h>
249+
250+ int main ( void ) {
251+ // Create a data buffer:
252+ const float data[ ] = { 1.0f, -2.0f, 3.0f, -4.0f, 5.0f, -6.0f, 7.0f, -8.0f };
253+
254+ // Specify the number of array dimensions:
255+ const int64_t ndims = 1;
256+
257+ // Specify the array shape:
258+ int64_t shape[] = { 4 };
259+
260+ // Specify the array strides:
261+ int64_t strides[] = { 2*STDLIB_NDARRAY_FLOAT32_BYTES_PER_ELEMENT };
262+
263+ // Specify the byte offset:
264+ const int64_t offset = 0;
265+
266+ // Specify the array order:
267+ const enum STDLIB_NDARRAY_ORDER order = STDLIB_NDARRAY_ROW_MAJOR;
268+
269+ // Specify the index mode:
270+ const enum STDLIB_NDARRAY_INDEX_MODE imode = STDLIB_NDARRAY_INDEX_ERROR;
271+
272+ // Specify the subscript index modes:
273+ int8_t submodes[] = { STDLIB_NDARRAY_INDEX_ERROR };
274+ const int64_t nsubmodes = 1;
275+
276+ // Create an input ndarray:
277+ struct ndarray *x = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)data, ndims, shape, strides, offset, order, imode, nsubmodes, submodes );
278+ if ( x == NULL ) {
279+ fprintf( stderr, "Error allocating memory.\n" );
280+ exit( 1 );
281+ }
282+
283+ // Specify the array strides for zero-dimensional ndarrays:
284+ int64_t sstrides[] = { 0 };
285+
286+ // Create a data buffer for an ndarray containing the search element:
287+ const float sdata[] = { 1.0f };
288+
289+ // Create a zero-dimensional ndarray containing the search element:
290+ struct ndarray *searchElement = stdlib_ndarray_allocate( STDLIB_NDARRAY_FLOAT32, (uint8_t *)sdata, 0, NULL, sstrides, 0, order, imode, nsubmodes, submodes );
291+ if ( searchElement == NULL ) {
292+ fprintf( stderr, "Error allocating memory.\n" );
293+ exit( 1 );
294+ }
295+
296+ // Create a data buffer for an ndarray containing the index from which to begin searching:
297+ const int32_t fdata[] = { 0 };
298+
299+ // Create a zero-dimensional ndarray containing the index from which to begin searching:
300+ struct ndarray *fromIndex = stdlib_ndarray_allocate( STDLIB_NDARRAY_INT32, (uint8_t *)fdata, 0, NULL, sstrides, 0, order, imode, nsubmodes, submodes );
301+ if ( fromIndex == NULL ) {
302+ fprintf( stderr, "Error allocating memory.\n" );
303+ exit( 1 );
304+ }
305+
306+ // Define a list of ndarrays:
307+ const struct ndarray *arrays[] = { x, searchElement, fromIndex };
308+
309+ // Resolve the index:
310+ CBLAS_INT idx = stdlib_blas_ext_sindex_of_not_equal( arrays );
311+
312+ // Print the result:
313+ printf( "index: %i\n", (int)idx );
314+
315+ // Free allocated memory:
316+ stdlib_ndarray_free( x );
317+ stdlib_ndarray_free( searchElement );
318+ stdlib_ndarray_free( fromIndex );
319+ }
320+ ```
321+
322+ </section>
323+
324+ <!-- /.examples -->
325+
326+ </section>
327+
328+ <!-- /.c -->
329+
140330<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
141331
142332<section class="related">
0 commit comments