@stdlib/ndarray-base-napi-dtype-string-to-dtype
v0.2.2
Published
C API for returning the ndarray data type corresponding to a data type string.
Downloads
14
Readme
Node-API ndarray dtype
C API for returning the ndarray data type corresponding to a data type string.
Installation
npm install @stdlib/ndarray-base-napi-dtype-string-to-dtype
Usage
#include "stdlib/ndarray/base/napi/dtype_string_to_dtype.h"
stdlib_ndarray_napi_dtype_string_to_dtype( const char *str )
Returns the ndarray data type corresponding to a data type string.
#include "stdlib/ndarray/base/napi/dtype_string_to_dtype.h"
#include "stdlib/ndarray/dtypes.h"
#include <node_api.h>
#include <assert.h>
// Add-on function export...
napi_value addon( napi_env env, napi_callback_info info ) {
// ...
// Get function arguments...
size_t argc = 1;
napi_value argv[ 1 ];
napi_status status = napi_get_cb_info( env, info, &argc, argv, nullptr, nullptr );
assert( status == napi_ok );
// ...
// Get a string argument...
char str[ 1024 ];
size_t len;
status = napi_get_value_string_utf8( env, argv[ 0 ], (char *)str, 1024, &len );
assert( status == napi_ok );
// ...
// Return the corresponding ndarray data type for the input typed array:
enum STDLIB_NDARRAY_DTYPE dtype = stdlib_ndarray_napi_dtype_string_to_dtype( str );
// ...
}
Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, 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.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2024. The Stdlib Authors.