Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

nans

Create a NaN-filled ndarray having a specified shape and data type.

Usage

var nans = require( '@stdlib/ndarray/base/nans' );

nans( dtype, shape, order )

Creates a NaN-filled ndarray having a specified shape and data type.

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

var arr = nans( 'float64', [ 2, 2 ], 'row-major' );
// returns <ndarray>[ [ NaN, NaN ], [ NaN, NaN ] ]

var dt = String( getDType( arr ) );
// returns 'float64'

The function accepts the following arguments:

  • dtype: underlying data type. Must be a floating-point or "generic" data type.
  • shape: array shape.
  • order: specifies whether an ndarray is 'row-major' (C-style) or 'column-major' (Fortran-style).

Examples

var ndarray2array = require( '@stdlib/ndarray/to-array' );
var nans = require( '@stdlib/ndarray/base/nans' );

var dt = [
    'float64',
    'float32',
    'complex128',
    'complex64',
    'generic'
];

// Generate NaN-filled arrays...
var arr;
var i;
for ( i = 0; i < dt.length; i++ ) {
    arr = nans( dt[ i ], [ 2, 2 ], 'row-major' );
    console.log( ndarray2array( arr ) );
}