Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

trues

Create an ndarray filled with true values and having a specified shape and data type.

Usage

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

trues( dtype, shape, order )

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:

  • dtype: underlying data type. Must be a boolean 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 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 ) );