@stdlib/ndarray-base-buffer
v0.3.0
Published
Create a contiguous linear ndarray data buffer.
Downloads
3,552
Readme
Contiguous Data Buffer
Create a contiguous linear ndarray data buffer.
Installation
npm install @stdlib/ndarray-base-buffer
Usage
var buffer = require( '@stdlib/ndarray-base-buffer' );
buffer( dtype, size )
Returns a contiguous linear ndarray data buffer having a specified data type.
var buf = buffer( 'float64', 3 );
// returns <Float64Array>[ 0.0, 0.0, 0.0 ]
If provided an unknown or unsupported data type, the function returns null
.
var buf = buffer( 'float', 3 );
// returns null
Notes
- When provided a numeric data type, "generic", or "binary", the function returns a zero-filled contiguous linear ndarray data buffer.
Examples
var dtypes = require( '@stdlib/ndarray-dtypes' );
var buffer = require( '@stdlib/ndarray-base-buffer' );
var DTYPES = dtypes();
var buf;
var i;
for ( i = 0; i < DTYPES.length; i++ ) {
buf = buffer( DTYPES[ i ], 10 );
console.log( buf );
}
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.