ndarray
Multidimensional arrays.
Installation
npm install @stdlib/ndarray
Alternatively,
- To load the package in a website via a
script
tag without installation and bundlers, use the ES Module available on theesm
branch. - If you are using Deno, visit the
deno
branch. - For use in Observable, or in browser/node environments, use the Universal Module Definition (UMD) build available on the
umd
branch.
The branches.md file summarizes the available branches and displays a diagram illustrating their relationships.
Usage
var ns = require( '@stdlib/ndarray' );
ns
ndarray namespace.
var o = ns;
// returns {...}
The namespace exports the following functions to create multidimensional arrays:
array( [buffer,] [options] )
: create a multidimensional array.ndarray( dtype, buffer, shape, strides, offset, order[, options] )
: multidimensional array constructor.
The namespace contains the following sub-namespaces:
base
: base ndarray.
In addition, the namespace contains the following multidimensional array utility functions:
ndarrayCastingModes()
: list of ndarray casting modes.defaults()
: default ndarray settings.dispatch( fcns, types, data, nargs, nin, nout )
: create an ndarray function interface which performs multiple dispatch.dispatch( fcns, types, data, nargs, nin, nout )
: create an ndarray function interface which performs multiple dispatch.ndarrayDataTypes( [kind] )
: list of ndarray data types.ndemptyLike( x[, options] )
: create an uninitialized ndarray having the same shape and data type as a provided ndarray.ndempty( shape[, options] )
: create an uninitialized ndarray having a specified shape and data type.scalar2ndarray( value[, options] )
: convert a scalar value to a zero-dimensional ndarray.ind2sub( shape, idx[, options] )
: convert a linear index to an array of subscripts.ndarrayIndexModes()
: list of ndarray index modes.ndarrayMinDataType( value )
: determine the minimum ndarray data type of the closest "kind" necessary for storing a provided scalar value.ndarrayNextDataType( [dtype] )
: return the next larger ndarray data type of the same kind.ndarrayOrders()
: list of ndarray orders.ndarrayOutputDataTypePolicies()
: list of output ndarray data type policies.ndarrayPromotionRules( [dtype1, dtype2] )
: return the ndarray data type with the smallest size and closest "kind" to which ndarray data types can be safely cast.ndarraySafeCasts( [dtype] )
: return a list of ndarray data types to which a provided ndarray data type can be safely cast.ndarraySameKindCasts( [dtype] )
: return a list of ndarray data types to which a provided ndarray data type can be safely cast or cast within the same "kind".sub2ind( shape, ...subscripts[, options] )
: convert subscripts to a linear index.ndarray2array( arr )
: convert an ndarray to a generic array.ndzerosLike( x[, options] )
: create a zero-filled ndarray having the same shape and data type as a provided ndarray.ndzeros( shape[, options] )
: create a zero-filled ndarray having a specified shape and data type.
Examples
var objectKeys = require( '@stdlib/utils/keys' );
var ns = require( '@stdlib/ndarray' );
console.log( objectKeys( ns ) );
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-2023. The Stdlib Authors.