List of ndarray data types.
var dtypes = require( '@stdlib/ndarray/dtypes' );Returns a list of ndarray data types.
var out = dtypes();
// e.g., returns [ 'binary', 'complex64', 'complex128', ... ]When not provided a data type "kind", the function returns an array containing the following data types:
binary: binary.complex64: single-precision complex floating-point numbers.complex128: double-precision complex floating-point numbers.float32: single-precision floating-point numbers.float64: double-precision floating-point numbers.generic: values of any type.int16: signed 16-bit integers.int32: signed 32-bit integers.int8: signed 8-bit integers.uint16: unsigned 16-bit integers.uint32: unsigned 32-bit integers.uint8: unsigned 8-bit integers.uint8c: unsigned clamped 8-bit integers.
To return the subset of data types belonging to a specified data type kind, provide a kind argument.
var out = dtypes( 'floating_point' );
// returns [...]The function supports the following data type kinds:
floating_point: floating-point data types.real_floating_point: real-valued floating-point data types.complex_floating_point: complex-valued floating-point data types.integer: integer data types.signed_integer: signed integer data types.unsigned_integer: unsigned integer data types.real: real-valued data types.numeric: numeric data types.typed: typed data types.all: all data types.
var indexOf = require( '@stdlib/utils/index-of' );
var dtypes = require( '@stdlib/ndarray/dtypes' );
var DTYPES = dtypes();
function isdtype( str ) {
if ( indexOf( DTYPES, str ) === -1 ) {
return false;
}
return true;
}
var bool = isdtype( 'float64' );
// returns true
bool = isdtype( 'int16' );
// returns true
bool = isdtype( 'uint8' );
// returns true
bool = isdtype( 'beep' );
// returns false@stdlib/array/dtypes: list of array data types.@stdlib/ndarray/array: multidimensional arrays.@stdlib/ndarray/ctor: multidimensional array constructor.@stdlib/array/typed-dtypes: list of typed array data types.