Contiguous Data Buffer
Create a contiguous linear ndarray data 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 );
}