Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

array2ndarray

Convert an array to a one-dimensional ndarray.

Usage

var array2ndarray = require( '@stdlib/ndarray/base/from-array' );

array2ndarray( buf, order )

Returns a one-dimensional ndarray which wraps a provided input array.

var getShape = require( '@stdlib/ndarray/shape' );
var getDType = require( '@stdlib/ndarray/dtype' );

var x = array2ndarray( [ 1, 2, 3 ], 'row-major' );
// returns <ndarray>

var sh = getShape( x );
// returns [ 3 ]

var dt = String( getDType( x ) );
// returns 'generic'

The function supports the following parameters:

  • buf: input array.
  • order: memory layout. Must be either 'row-major' or 'column-major'.

Examples

var getDType = 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' );
var dt = String( getDType( x ) );
// returns 'float64'

buf = typedarray( 10, 'int32' );
x = array2ndarray( buf, 'row-major' );
dt = String( getDType( x ) );
// returns 'int32'

buf = typedarray( 10, 'complex128' );
x = array2ndarray( buf, 'row-major' );
dt = String( getDType( x ) );
// returns 'complex128'

buf = typedarray( 10, 'bool' );
x = array2ndarray( buf, 'row-major' );
dt = String( getDType( x ) );
// returns 'bool'