-
-
Notifications
You must be signed in to change notification settings - Fork 447
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into de…
…velop
- Loading branch information
Showing
10 changed files
with
113 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -8,6 +8,7 @@ Athan Reines <[email protected]> | |
Brendan Graetz <[email protected]> | ||
Bruno Fenzl <[email protected]> | ||
Christopher Dambamuromo <[email protected]> | ||
Dan Rose <[email protected]> | ||
Dominik Moritz <[email protected]> | ||
Dorrin Sotoudeh <[email protected]> | ||
Frank Kovacs <[email protected]> | ||
|
76 changes: 76 additions & 0 deletions
76
lib/node_modules/@stdlib/ndarray/dispatch-by/test/fixtures/fill.js
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2023 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var ind2sub = require( '@stdlib/ndarray/ind2sub' ); | ||
var numel = require( '@stdlib/ndarray/base/numel' ); | ||
|
||
|
||
// MAIN // | ||
|
||
/** | ||
* Return an ndarray function which fills one or more ndarrays. | ||
* | ||
* @private | ||
* @param {*} value - fill value | ||
* @returns {Function} ndarray function | ||
*/ | ||
function fill( value ) { | ||
return ndarrayFcn; | ||
|
||
/** | ||
* ndarray function. | ||
* | ||
* @private | ||
* @param {Array<ndarrayLike>} arrays - ndarrays | ||
*/ | ||
function ndarrayFcn( arrays ) { | ||
var opts; | ||
var sub; | ||
var arr; | ||
var sh; | ||
var M; | ||
var N; | ||
var i; | ||
var j; | ||
|
||
sh = arrays[ 0 ].shape; | ||
N = numel( sh ); | ||
M = arrays.length; | ||
opts = { | ||
'order': '' | ||
}; | ||
for ( j = 0; j < M; j++ ) { | ||
arr = arrays[ j ]; | ||
opts.order = arrays[ j ].order; | ||
for ( i = 0; i < N; i++ ) { | ||
sub = ind2sub( sh, i, opts ); | ||
sub.push( value ); | ||
arr.set.apply( arr, sub ); | ||
} | ||
} | ||
} | ||
} | ||
|
||
|
||
// EXPORTS // | ||
|
||
module.exports = fill; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters