@stdlib/ndarray-ndarraylike2ndarray
v0.1.1
Published
Convert an ndarray-like object to an ndarray.
Downloads
17
Readme
ndarraylike2ndarray
Convert an ndarray-like object to an
ndarray.
Installation
npm install @stdlib/ndarray-ndarraylike2ndarrayUsage
var ndarraylike2ndarray = require( '@stdlib/ndarray-ndarraylike2ndarray' );ndarraylike2ndarray( x[, options] )
Converts an ndarray-like object to an ndarray.
var array = require( '@stdlib/ndarray-array' );
var arr = array( [ [ 1, 2 ], [ 3, 4 ] ] );
var out = ndarraylike2ndarray( arr );
// returns <ndarray>The function supports the same options as ndarray.
Notes
Examples
var array = require( '@stdlib/ndarray-array' );
var ndarraylike2ndarray = require( '@stdlib/ndarray-ndarraylike2ndarray' );
// Create an ndarray:
var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
// Create another ndarray sharing the same data:
var out = ndarraylike2ndarray( x );
// returns <ndarray>
// Print various properties:
console.log( 'dtype: %s', out.dtype );
console.log( 'ndims: %d', out.shape.length );
console.log( 'length: %d', out.length );
console.log( 'shape: [ %s ]', out.shape.join( ', ' ) );
console.log( 'strides: [ %s ]', out.strides.join( ', ' ) );
console.log( 'offset: %d', out.offset );
console.log( 'order: %s', out.order );See Also
@stdlib/ndarray-array: multidimensional arrays.@stdlib/ndarray-ctor: multidimensional array constructor.@stdlib/ndarray-empty-like: create an uninitialized ndarray having the same shape and data type as a provided ndarray.@stdlib/ndarray-zeros-like: create a zero-filled ndarray having the same shape and data type as a provided ndarray.
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-2026. The Stdlib Authors.
