|
| 1 | +/* |
| 2 | +* @license Apache-2.0 |
| 3 | +* |
| 4 | +* Copyright (c) 2024 The Stdlib Authors. |
| 5 | +* |
| 6 | +* Licensed under the Apache License, Version 2.0 (the "License"); |
| 7 | +* you may not use this file except in compliance with the License. |
| 8 | +* You may obtain a copy of the License at |
| 9 | +* |
| 10 | +* http://www.apache.org/licenses/LICENSE-2.0 |
| 11 | +* |
| 12 | +* Unless required by applicable law or agreed to in writing, software |
| 13 | +* distributed under the License is distributed on an "AS IS" BASIS, |
| 14 | +* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
| 15 | +* See the License for the specific language governing permissions and |
| 16 | +* limitations under the License. |
| 17 | +*/ |
| 18 | + |
| 19 | +// TypeScript Version: 4.1 |
| 20 | + |
| 21 | +/// <reference types="@stdlib/types"/> |
| 22 | + |
| 23 | +import { Array1D, Array2D, Array3D, Array4D,Array5D } from '@stdlib/types/array'; |
| 24 | +import { Shape1D, Shape2D, Shape3D, Shape4D, Shape5D } from '@stdlib/types/ndarray'; |
| 25 | + |
| 26 | +/** |
| 27 | +* Quinary callback. |
| 28 | +* |
| 29 | +* @param v1 - element from first input array |
| 30 | +* @param v2 - element from second input array |
| 31 | +* @param v3 - element from third input array |
| 32 | +* @param v4 - element from fourth input array |
| 33 | +* @param v5 - element from fifth input array |
| 34 | +* @returns result |
| 35 | +*/ |
| 36 | +type Quinary<T, U, V, W, X, Y> = ( v1: T, v2: U, v3: V, v4: W, v5: X ) => Y; |
| 37 | + |
| 38 | +/** |
| 39 | +* Input array. |
| 40 | +*/ |
| 41 | +type InputArray<T> = Array5D<T>; |
| 42 | + |
| 43 | +/** |
| 44 | +* Input array shape. |
| 45 | +*/ |
| 46 | +type InputArrayShape = Shape5D; |
| 47 | + |
| 48 | +/** |
| 49 | +* Output array. |
| 50 | +*/ |
| 51 | +type OutputArray<T> = Array5D<T>; |
| 52 | + |
| 53 | +/** |
| 54 | +* Output array shape. |
| 55 | +*/ |
| 56 | +type OutputArrayShape = Shape5D; |
| 57 | + |
| 58 | +/** |
| 59 | +* Input and output arrays. |
| 60 | +*/ |
| 61 | +type InOutArrays<T, U, V, W, X, Y> = [ |
| 62 | + InputArray<T>, |
| 63 | + InputArray<U>, |
| 64 | + InputArray<V>, |
| 65 | + InputArray<W>, |
| 66 | + InputArray<X>, |
| 67 | + OutputArray<Y> |
| 68 | +]; |
| 69 | + |
| 70 | +/** |
| 71 | +* Input and output array shapes. |
| 72 | +*/ |
| 73 | +type InOutShapes = [ |
| 74 | + InputArrayShape, |
| 75 | + InputArrayShape, |
| 76 | + InputArrayShape, |
| 77 | + InputArrayShape, |
| 78 | + InputArrayShape, |
| 79 | + OutputArrayShape |
| 80 | +]; |
| 81 | + |
| 82 | +/** |
| 83 | +* Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a five-dimensional nested output array. |
| 84 | +* |
| 85 | +* ## Notes |
| 86 | +* |
| 87 | +* - The input array shapes must be broadcast compatible with the output array shape. |
| 88 | +* |
| 89 | +* @param arrays - array containing five input nested arrays and one output nested array |
| 90 | +* @param shapes - array shapes |
| 91 | +* @param fcn - quinary callback |
| 92 | +* |
| 93 | +* @example |
| 94 | +* var ones5d = require( '@stdlib/array/base/ones5d' ); |
| 95 | +* var zeros5d = require( '@stdlib/array/base/zeros5d' ); |
| 96 | +* |
| 97 | +* function add( x, y, z, w, v ) { |
| 98 | +* return x + y + z + w + v; |
| 99 | +* } |
| 100 | +* |
| 101 | +* var shapes = [ |
| 102 | +* [ 1, 1, 1, 2, 2 ], |
| 103 | +* [ 1, 1, 2, 1, 2 ], |
| 104 | +* [ 1, 1, 1, 1, 1 ], |
| 105 | +* [ 1, 1, 1, 1, 1 ], |
| 106 | +* [ 1, 1, 1, 1, 1 ], |
| 107 | +* [ 1, 1, 2, 2, 2 ] |
| 108 | +* ]; |
| 109 | +* |
| 110 | +* var x = ones5d( shapes[ 0 ] ); |
| 111 | +* var y = ones5d( shapes[ 1 ] ); |
| 112 | +* var z = ones5d( shapes[ 2 ] ); |
| 113 | +* var w = ones5d( shapes[ 3 ] ); |
| 114 | +* var v = ones5d( shapes[ 4 ] ); |
| 115 | +* var out = zeros5d( shapes[ 5 ] ); |
| 116 | +* |
| 117 | +* bquinary5d( [ x, y, z, w, v, out ], shapes, add ); |
| 118 | +* |
| 119 | +* console.log( out ); |
| 120 | +* // => [ [ [ [ [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ] ] ] ], [ [ [ [ 5.0, 5.0 ] ], [ [ 5.0, 5.0 ] ] ] ] ] |
| 121 | +*/ |
| 122 | +declare function bquinary5d<T = unknown, U = unknown, V = unknown, W = unknown, X = unknown, Y = unknown>( arrays: InOutArrays<T, U, V, W, X, Y>, shapes: InOutShapes, fcn: Quinary<T, U, V, W, X, Y> ): void; |
| 123 | + |
| 124 | + |
| 125 | +// EXPORTS // |
| 126 | + |
| 127 | +export = bquinary5d; |
0 commit comments