data

Return the underlying data buffer of a provided ndarray.

Usage

var data = require( '@stdlib/ndarray/data-buffer' );

data( x )

Returns the underlying data buffer of a provided ndarray.

var zeros = require( '@stdlib/ndarray/zeros' );

var x = zeros( [ 3, 2, 3 ], {
    'dtype': 'float64'
});
// returns <ndarray>

var out = data( x );
// returns <Float64Array>

Examples

var zeros = require( '@stdlib/ndarray/zeros' );
var data = require( '@stdlib/ndarray/data-buffer' );

// Create a 'float64' array...
var opts = {
    'dtype': 'float64'
};
var x = zeros( [ 2, 2 ], opts );
// returns <ndarray>

var buf = data( x );
// returns <Float64Array>

// Create a 'float32' array...
opts = {
    'dtype': 'float32'
};
x = zeros( [ 2, 2 ], opts );
// returns <ndarray>

buf = data( x );
// returns <Float32Array>

// Create a 'complex128' array...
opts = {
    'dtype': 'complex128'
};
x = zeros( [ 2, 2 ], opts );
// returns <ndarray>

buf = data( x );
// returns <Complex128Array>

// Create an 'int32' array...
opts = {
    'dtype': 'int32'
};
x = zeros( [ 2, 2 ], opts );
// returns <ndarray>

buf = data( x );
// returns <Int32Array>
Did you find this page helpful?