Skip to content

Latest commit

 

History

History

Folders and files

NameName
Last commit message
Last commit date

parent directory

..
 
 
 
 
 
 
 
 
 
 
 
 
 
 

README.md

falsesLike

Create an ndarray filled with false values and having the same shape and data type as a provided ndarray.

Usage

var falsesLike = require( '@stdlib/ndarray/base/falses-like' );

falsesLike( x )

Creates an ndarray filled with false values and having the same shape and data type as a provided ndarray.

var getShape = require( '@stdlib/ndarray/shape' );
var empty = require( '@stdlib/ndarray/empty' );

var x = empty( [ 2, 2 ], {
    'dtype': 'bool'
});
// returns <ndarray>

var y = falsesLike( x );
// returns <ndarray>[ [ false, false ], [ false, false ] ]

var sh = getShape( y );
// returns [ 2, 2 ]

Notes

  • Along with data type, shape, and order, the function infers the "class" of the returned ndarray from the provided ndarray. For example, if provided a "base" ndarray, the function returns a base ndarray. If provided a non-base ndarray, the function returns a non-base ndarray.

Examples

var empty = require( '@stdlib/ndarray/empty' );
var ndarray2array = require( '@stdlib/ndarray/to-array' );
var falsesLike = require( '@stdlib/ndarray/base/falses-like' );

// Specify a list of data types:
var dt = [
    'generic',
    'bool'
];

// Generate false-filled arrays...
var x;
var y;
var i;
for ( i = 0; i < dt.length; i++ ) {
    x = empty( [ 2, 2 ], {
        'dtype': dt[ i ]
    });
    y = falsesLike( x );
    console.log( ndarray2array( y ) );
}