@stdlib/ndarray-base-promote-dtypes
v0.1.1
Published
Resolve the data type that results from applying promotion rules to a provided list of data types.
Readme
promoteDataTypes
Resolve the data type that results from applying promotion rules to a provided list of data types.
Installation
npm install @stdlib/ndarray-base-promote-dtypesUsage
var promoteDataTypes = require( '@stdlib/ndarray-base-promote-dtypes' );promoteDataTypes( dtypes )
Returns a data type that results from applying promotion rules to a provided list of data types.
var dt = promoteDataTypes( [ 'float32', 'float64' ] );
// returns 'float64'The function returns null if provided data types which cannot be safely cast to a promoted data type.
var dt = promoteDataTypes( [ 'binary', 'complex128' ] );
// returns nullExamples
var dtypes = require( '@stdlib/ndarray-dtypes' );
var cartesianProduct = require( '@stdlib/array-base-cartesian-product' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var promoteDataTypes = require( '@stdlib/ndarray-base-promote-dtypes' );
// Get the list of supported data types:
var dt = dtypes();
// Generate data type pairs:
var pairs = cartesianProduct( dt, dt );
// Resolve promoted data types:
logEachMap( '(%s) => %s', pairs, promoteDataTypes );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-2026. The Stdlib Authors.
