@stdlib/math-array-tools
v0.1.1
Published
Math array function tools.
Downloads
38
Readme
Tools
Math array function tools.
Installation
npm install @stdlib/math-array-toolsUsage
var ns = require( '@stdlib/math-array-tools' );ns
Namespace containing tools for applying mathematical functions to arrays.
var o = ns;
// returns {...}The namespace contains the following:
unaryFactory( fcn, idtypes, odtypes, policy ): create a function for applying a unary function to each element in an input array.unary( fcn, idtypes, odtypes, policy ): constructor for applying a unary function to each element in an input array.
Examples
var abs = require( '@stdlib/math-base-special-abs' );
var ns = require( '@stdlib/math-array-tools' );
// Define a list of supported input dtypes:
var idtypes = [
'float64',
'float32',
'generic'
];
// Define a list of supported output dtypes:
var odtypes = [
'float64',
'float32',
'generic'
];
// Create a function for applying a unary function to each element of an array:
var f = new ns.unary( abs, idtypes, odtypes, 'same' );
// Create an input array:
var x = [ -1.0, 2.0, -3.0, 4.0 ];
// Perform element-wise computation:
var out = f.apply( x );
// returns [ 1.0, 2.0, 3.0, 4.0 ]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.
