Skip to content

stdlib-js/blas-ext-base-ndarray-gfill-not-equal

 
 

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

3 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

About stdlib...

We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.

The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.

When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.

To join us in bringing numerical computing to the web, get started by checking us out on GitHub, and please consider financially supporting stdlib. We greatly appreciate your continued support!

gfillNotEqual

NPM version Build Status Coverage Status

Replace elements in a one-dimensional ndarray not equal to a provided search element with a specified scalar constant.

Usage

import gfillNotEqual from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-ndarray-gfill-not-equal@esm/index.mjs';

gfillNotEqual( arrays )

Replaces elements in a one-dimensional ndarray not equal to a provided search element with a specified scalar constant.

import vector from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-vector-ctor@esm/index.mjs';
import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-scalar@esm/index.mjs';

var x = vector( [ 0.0, -2.0, 3.0, 0.0, 4.0, -6.0 ], 'generic' );

var searchElement = scalar2ndarray( 0.0, {
    'dtype': 'generic'
});

var alpha = scalar2ndarray( 5.0, {
    'dtype': 'generic'
});

gfillNotEqual( [ x, searchElement, alpha ] );
// x => <ndarray>[ 0.0, 5.0, 5.0, 0.0, 5.0, 5.0 ]

The function has the following parameters:

  • arrays: array-like object containing the following ndarrays:

    • a one-dimensional input ndarray.
    • a zero-dimensional ndarray containing the search element.
    • a zero-dimensional ndarray containing the scalar constant.

Notes

  • The input ndarray is modified in-place (i.e., the input ndarray is mutated).
  • When comparing elements, the function checks for equality using the strict equality operator ===. As a consequence, NaN values are considered distinct (i.e., as NaN !== NaN always evaluates to true, NaN elements are always replaced), and -0 and +0 are considered the same.

Examples

<!DOCTYPE html>
<html lang="en">
<body>
<script type="module">

import discreteUniform from 'https://cdn.jsdelivr.net/gh/stdlib-js/random-discrete-uniform@esm/index.mjs';
import scalar2ndarray from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-from-scalar@esm/index.mjs';
import ndarray2array from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-to-array@esm/index.mjs';
import ndarraylike2scalar from 'https://cdn.jsdelivr.net/gh/stdlib-js/ndarray-ndarraylike2scalar@esm/index.mjs';
import gfillNotEqual from 'https://cdn.jsdelivr.net/gh/stdlib-js/blas-ext-base-ndarray-gfill-not-equal@esm/index.mjs';

var opts = {
    'dtype': 'generic'
};

var x = discreteUniform( [ 10 ], 0, 3, opts );
console.log( ndarray2array( x ) );

var searchElement = scalar2ndarray( 1, opts );
console.log( 'Search Element: %d', ndarraylike2scalar( searchElement ) );

var alpha = scalar2ndarray( 5, opts );
console.log( 'Alpha: %d', ndarraylike2scalar( alpha ) );

gfillNotEqual( [ x, searchElement, alpha ] );
console.log( ndarray2array( x ) );

</script>
</body>
</html>

Notice

This package is part of stdlib, a standard library with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.

For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.

Community

Chat


License

See LICENSE.

Copyright

Copyright © 2016-2026. The Stdlib Authors.

About

Replace elements in a one-dimensional ndarray not equal to a provided search element with a specified scalar constant.

Topics

Resources

Security policy

Stars

Watchers

Forks

Releases

Packages

Contributors

Languages