Serialize an ndarray as a string.
var ndarray2string = require( '@stdlib/ndarray/to-string' );Serializes an ndarray as a string.
var array = require( '@stdlib/ndarray/array' );
var x = array( [ 1, 2, 3, 4 ], {
'shape': [ 2, 2 ]
});
// returns <ndarray>
var str = ndarray2string( x );
// returns "ndarray( 'float64', new Float64Array( [ 1, 2, 3, 4 ] ), [ 2, 2 ], [ 2, 1 ], 0, 'row-major' )"- The function does not serialize data outside of the buffer defined by the ndarray view.
- For ndarrays with more than
100elements, the function abbreviates the data, showing only the first and last three values.
var array = require( '@stdlib/ndarray/array' );
var ndarray2string = require( '@stdlib/ndarray/to-string' );
// Create a 2x3 ndarray:
var x = array( [ 1, 2, 3, 4, 5, 6 ], {
'shape': [ 2, 3 ],
'dtype': 'generic'
});
// Serialize the ndarray as a string:
var str = ndarray2string( x );
console.log( str );
// => 'ndarray( \'generic\', [ 1, 2, 3, 4, 5, 6 ], [ 2, 3 ], [ 3, 1 ], 0, \'row-major\' )'