Convert an array to a one-dimensional ndarray.
var array2ndarray = require( '@stdlib/ndarray/base/from-array' );Returns a one-dimensional ndarray which wraps a provided input array.
var x = array2ndarray( [ 1, 2, 3 ], 'row-major' );
// returns <ndarray>
var sh = x.shape;
// returns [ 3 ]
var dt = x.dtype;
// returns 'generic'The function supports the following parameters:
- buf: input array.
- order: memory layout. Must be either
'row-major'or'column-major'.
var dtype = require( '@stdlib/ndarray/dtype' );
var typedarray = require( '@stdlib/array/typed' );
var array2ndarray = require( '@stdlib/ndarray/base/from-array' );
var buf = typedarray( 10, 'float64' );
var x = array2ndarray( buf, 'row-major' );
console.log( dtype( x ) );
// => 'float64'
buf = typedarray( 10, 'int32' );
x = array2ndarray( buf, 'row-major' );
console.log( dtype( x ) );
// => 'int32'
buf = typedarray( 10, 'complex128' );
x = array2ndarray( buf, 'row-major' );
console.log( dtype( x ) );
// => 'complex128'
buf = typedarray( 10, 'bool' );
x = array2ndarray( buf, 'row-major' );
console.log( dtype( x ) );
// => 'bool'