Create an ndarray filled with
falsevalues and having a specified shape and data type.
var falses = require( '@stdlib/ndarray/falses' );Creates an ndarray filled with false values and having a specified shape and data type.
var getShape = require( '@stdlib/ndarray/shape' );
var getDType = require( '@stdlib/ndarray/dtype' );
var arr = falses( [ 2, 2 ] );
// returns <ndarray>[ [ false, false ], [ false, false ] ]
var sh = getShape( arr );
// returns [ 2, 2 ]
var dt = String( getDType( arr ) );
// returns 'bool'The specified output ndarray shape may be either an array-like object or an integer value.
var getShape = require( '@stdlib/ndarray/shape' );
var getDType = require( '@stdlib/ndarray/dtype' );
var arr = falses( 2 );
// returns <ndarray>[ false, false ]
var sh = getShape( arr );
// returns [ 2 ]
var dt = String( getDType( arr ) );
// returns 'bool'The function accepts the following options:
- dtype: underlying data type. Must be a boolean or "generic" data type. Default:
'bool'. - order: specifies whether an ndarray is
'row-major'(C-style) or'column-major'(Fortran-style). Default:'row-major'. - mode: specifies how to handle indices which exceed array dimensions (see ndarray). Default:
'throw'. - submode: a mode array which specifies for each dimension how to handle subscripts which exceed array dimensions (see ndarray). If provided fewer modes than dimensions, the constructor recycles modes using modulo arithmetic. Default:
[ options.mode ]. - readonly: boolean indicating whether an array should be read-only. Default:
false.
By default, the function returns an ndarray having a bool data type. To specify an alternative data type, provide a dtype option.
var getShape = require( '@stdlib/ndarray/shape' );
var getDType = require( '@stdlib/ndarray/dtype' );
var arr = falses( [ 2, 2 ], {
'dtype': 'generic'
});
// returns <ndarray>[ [ false, false ], [ false, false ] ]
var sh = getShape( arr );
// returns [ 2, 2 ]
var dt = String( getDType( arr ) );
// returns 'generic'var ndarray2array = require( '@stdlib/ndarray/to-array' );
var falses = require( '@stdlib/ndarray/falses' );
// Specify a list of data types:
var dt = [
'bool',
'generic'
];
// Generate filled ndarrays...
var arr;
var i;
for ( i = 0; i < dt.length; i++ ) {
arr = falses( [ 2, 2 ], {
'dtype': dt[ i ]
});
console.log( ndarray2array( arr ) );
}@stdlib/ndarray/array: multidimensional arrays.@stdlib/ndarray/ctor: multidimensional array constructor.