Create an ndarray filled with
truevalues and having a specified shape and data type.
var trues = require( '@stdlib/ndarray/base/trues' );Creates an ndarray filled with true values and having a specified shape and data type.
var getDType = require( '@stdlib/ndarray/dtype' );
var arr = trues( 'bool', [ 2, 2 ], 'row-major' );
// returns <ndarray>[ [ true, true ], [ true, true ] ]
var dt = String( getDType( arr ) );
// returns 'bool'The function accepts the following arguments:
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var trues = require( '@stdlib/ndarray/base/trues' );
var arr = trues( 'bool', [ 2, 2 ], 'row-major' );
console.log( ndarray2array( arr ) );
arr = trues( 'generic', [ 2, 2 ], 'row-major' );
console.log( ndarray2array( arr ) );