diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0c2727bb..4da968a6 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -3,28 +3,30 @@ # Contributors listed in alphabetical order. Ali Salesi +Amit Jimiwal Athan Reines Brendan Graetz Bruno Fenzl Christopher Dambamuromo Dominik Moritz +Dorrin Sotoudeh Frank Kovacs -Harshita Kalani <95532771+HarshitaKalani@users.noreply.github.com> -James +Harshita Kalani +James Gelok Jithin KS Joey Reed -Jordan-Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> +Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com> Joris Labie Justin Dennison -KATTA NAGA NITHIN <88046362+nithinkatta@users.noreply.github.com> -Marcus +Marcus Fantham Matt Cochrane Milan Raj Momtchil Momtchev -Naresh Jagadeesan <37257700+Infinage@users.noreply.github.com> +Naresh Jagadeesan +Nithin Katta <88046362+nithinkatta@users.noreply.github.com> Ognjen Jevremović Philipp Burckhardt -Pranav <85227306+Pranavchiku@users.noreply.github.com> +Pranav Goswami Ricky Reusser Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Ryan Seal @@ -32,7 +34,5 @@ Seyyed Parsa Neshaei Shraddheya Shendre Stephannie Jiménez Gacha Yernar Yergaziyev -dorrin-sot <59933477+dorrin-sot@users.noreply.github.com> -drunken_devv <90555965+amitjimiwal@users.noreply.github.com> orimiles5 <97595296+orimiles5@users.noreply.github.com> -rei2hu +rei2hu diff --git a/dispatch-by/test/fixtures/fill.js b/dispatch-by/test/fixtures/fill.js new file mode 100644 index 00000000..9b677030 --- /dev/null +++ b/dispatch-by/test/fixtures/fill.js @@ -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( './../../../ind2sub' ); +var numel = require( './../../../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} 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;