diff --git a/CONTRIBUTORS b/CONTRIBUTORS index 0dae4fe6..3bc3576e 100644 --- a/CONTRIBUTORS +++ b/CONTRIBUTORS @@ -29,6 +29,7 @@ Ognjen Jevremović Philipp Burckhardt Pranav Goswami Ricky Reusser +Robert Gislason Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com> Ryan Seal Seyyed Parsa Neshaei @@ -37,4 +38,3 @@ Stephannie Jiménez Gacha Yernar Yergaziyev orimiles5 <97595296+orimiles5@users.noreply.github.com> rei2hu -Robert Gislason diff --git a/base/docs/types/index.d.ts b/base/docs/types/index.d.ts index 21a916d6..b491cf35 100644 --- a/base/docs/types/index.d.ts +++ b/base/docs/types/index.d.ts @@ -36,6 +36,8 @@ import bbinary2d = require( './../../../base/broadcasted-binary2d' ); import bbinary3d = require( './../../../base/broadcasted-binary3d' ); import bbinary4d = require( './../../../base/broadcasted-binary4d' ); import bbinary5d = require( './../../../base/broadcasted-binary5d' ); +import bquaternary2d = require( './../../../base/broadcasted-quaternary2d' ); +import bquinary2d = require( './../../../base/broadcasted-quinary2d' ); import bternary2d = require( './../../../base/broadcasted-ternary2d' ); import bunary2d = require( './../../../base/broadcasted-unary2d' ); import bunary3d = require( './../../../base/broadcasted-unary3d' ); @@ -84,9 +86,18 @@ import ones3d = require( './../../../base/ones3d' ); import ones4d = require( './../../../base/ones4d' ); import ones5d = require( './../../../base/ones5d' ); import onesnd = require( './../../../base/onesnd' ); +import quaternary2d = require( './../../../base/quaternary2d' ); +import quinary2d = require( './../../../base/quinary2d' ); import setter = require( './../../../base/setter' ); +import strided2array2d = require( './../../../base/strided2array2d' ); +import strided2array3d = require( './../../../base/strided2array3d' ); +import strided2array4d = require( './../../../base/strided2array4d' ); +import strided2array5d = require( './../../../base/strided2array5d' ); import take = require( './../../../base/take' ); import ternary2d = require( './../../../base/ternary2d' ); +import ternary3d = require( './../../../base/ternary3d' ); +import ternary4d = require( './../../../base/ternary4d' ); +import ternary5d = require( './../../../base/ternary5d' ); import toAccessorArray = require( './../../../base/to-accessor-array' ); import unary2d = require( './../../../base/unary2d' ); import unary2dBy = require( './../../../base/unary2d-by' ); @@ -584,6 +595,88 @@ interface Namespace { */ bbinary5d: typeof bbinary5d; + /** + * Applies a quaternary callback to elements in four broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. + * + * ## Notes + * + * - The input array shapes must be broadcast compatible with the output array shape. + * + * @param arrays - array containing four input nested arrays and one output nested array + * @param shapes - array shapes + * @param fcn - quaternary callback + * + * @example + * var ones2d = require( `@stdlib/array/base/ones2d` ); + * var zeros2d = require( `@stdlib/array/base/zeros2d` ); + * + * function add( x, y, z, w ) { + * return x + y + z + w; + * } + * + * var shapes = [ + * [ 1, 2 ], + * [ 2, 1 ], + * [ 1, 1 ], + * [ 2, 2 ], + * [ 2, 2 ] + * ]; + * + * var x = ones2d( shapes[ 0 ] ); + * var y = ones2d( shapes[ 1 ] ); + * var z = ones2d( shapes[ 2 ] ); + * var w = ones2d( shapes[ 3 ] ); + * var out = zeros2d( shapes[ 4 ] ); + * + * ns.bquaternary2d( [ x, y, z, w, out ], shapes, add ); + * + * console.log( out ); + * // => [ [ 4.0, 8.0 ], [ 12.0, 16.0 ] ] + */ + bquaternary2d: typeof bquaternary2d; + + /** + * Applies a quinary callback to elements in five broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. + * + * ## Notes + * + * - The input array shapes must be broadcast compatible with the output array shape. + * + * @param arrays - array containing five input nested arrays and one output nested array + * @param shapes - array shapes + * @param fcn - quinary callback + * + * @example + * var ones2d = require( `@stdlib/array/base/ones2d` ); + * var zeros2d = require( `@stdlib/array/base/zeros2d` ); + * + * function add( x, y, z, w, v ) { + * return x + y + z + w + v; + * } + * + * var shapes = [ + * [ 1, 2 ], + * [ 2, 1 ], + * [ 1, 1 ], + * [ 2, 2 ], + * [ 1, 1 ], + * [ 2, 2 ] + * ]; + * + * var x = ones2d( shapes[ 0 ] ); + * var y = ones2d( shapes[ 1 ] ); + * var z = ones2d( shapes[ 2 ] ); + * var w = ones2d( shapes[ 3 ] ); + * var v = ones2d( shapes[ 4 ] ); + * var out = zeros2d( shapes[ 5 ] ); + * + * ns.bquinary2d( [ x, y, z, w, v, out ], shapes, add ); + * + * console.log( out ); + * // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] + */ + bquinary2d: typeof bquinary2d; + /** * Applies a ternary callback to elements in three broadcasted input arrays and assigns results to elements in a two-dimensional nested output array. * @@ -1628,6 +1721,75 @@ interface Namespace { */ onesnd: typeof onesnd; + /** + * Applies a quaternary callback to elements in four two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. + * + * ## Notes + * + * - The function assumes that the input and output arrays have the same shape. + * + * @param arrays - array containing four input nested arrays and one output nested array + * @param shape - array shape + * @param fcn - quaternary callback + * + * @example + * var ones2d = require( `@stdlib/array/base/ones2d` ); + * var zeros2d = require( `@stdlib/array/base/zeros2d` ); + * + * function add( x, y, z, w ) { + * return x + y + z + w; + * } + * + * var shape = [ 2, 2 ]; + * + * var x = ones2d( shape ); + * var y = ones2d( shape ); + * var z = ones2d( shape ); + * var w = ones2d( shape ); + * var out = zeros2d( shape ); + * + * ns.quaternary2d( [ x, y, z, w, out ], shape, add ); + * + * console.log( out ); + * // => [ [ 4.0, 4.0 ], [ 4.0, 4.0 ] ] + */ + quaternary2d: typeof quaternary2d; + + /** + * Applies a quinary callback to elements in five two-dimensional nested input arrays and assigns results to elements in a two-dimensional nested output array. + * + * ## Notes + * + * - The function assumes that the input and output arrays have the same shape. + * + * @param arrays - array containing five input nested arrays and one output nested array + * @param shape - array shape + * @param fcn - quinary callback + * + * @example + * var ones2d = require( `@stdlib/array/base/ones2d` ); + * var zeros2d = require( `@stdlib/array/base/zeros2d` ); + * + * function add( x, y, z, w, v ) { + * return x + y + z + w + v; + * } + * + * var shape = [ 2, 2 ]; + * + * var x = ones2d( shape ); + * var y = ones2d( shape ); + * var z = ones2d( shape ); + * var w = ones2d( shape ); + * var v = ones2d( shape ); + * var out = zeros2d( shape ); + * + * ns.quinary2d( [ x, y, z, w, v, out ], shape, add ); + * + * console.log( out ); + * // => [ [ 5.0, 5.0 ], [ 5.0, 5.0 ] ] + */ + quinary2d: typeof quinary2d; + /** * Returns an accessor function for setting an element in an indexed array-like object. * @@ -1647,6 +1809,114 @@ interface Namespace { */ setter: typeof setter; + /** + * Converts a strided array to a two-dimensional nested array. + * + * ## Notes + * + * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. + * + * @param x - input array + * @param shape - array shape + * @param strides - dimension strides + * @param offset - index of the first indexed value in the input array + * @returns two-dimensional nested array + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array2d( x, [ 3, 2 ], [ 2, 1 ], 0 ); + * // returns [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array2d( x, [ 3, 2 ], [ 1, 3 ], 0 ); + * // returns [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] + */ + strided2array2d: typeof strided2array2d; + + /** + * Converts a strided array to a three-dimensional nested array. + * + * ## Notes + * + * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. + * + * @param x - input array + * @param shape - array shape + * @param strides - dimension strides + * @param offset - index of the first indexed value in the input array + * @returns three-dimensional nested array + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array3d( x, [ 1, 3, 2 ], [ 6, 2, 1 ], 0 ); + * // returns [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array3d( x, [ 1, 3, 2 ], [ 1, 1, 3 ], 0 ); + * // returns [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] + */ + strided2array3d: typeof strided2array3d; + + /** + * Converts a strided array to a four-dimensional nested array. + * + * ## Notes + * + * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. + * + * @param x - input array + * @param shape - array shape + * @param strides - dimension strides + * @param offset - index of the first indexed value in the input array + * @returns four-dimensional nested array + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array4d( x, [ 1, 1, 3, 2 ], [ 6, 6, 2, 1 ], 0 ); + * // returns [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array4d( x, [ 1, 1, 3, 2 ], [ 1, 1, 1, 3 ], 0 ); + * // returns [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] + */ + strided2array4d: typeof strided2array4d; + + /** + * Converts a strided array to a five-dimensional nested array. + * + * ## Notes + * + * - The function assumes that the input array is compatible with the specified array shape, dimension strides, and index offset. + * + * @param x - input array + * @param shape - array shape + * @param strides - dimension strides + * @param offset - index of the first indexed value in the input array + * @returns five-dimensional nested array + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 6, 6, 6, 2, 1 ], 0 ); + * // returns [ [ [ [ [ 1, 2 ], [ 3, 4 ], [ 5, 6 ] ] ] ] ] + * + * @example + * var x = [ 1, 2, 3, 4, 5, 6 ]; + * + * var arr = ns.strided2array5d( x, [ 1, 1, 1, 3, 2 ], [ 1, 1, 1, 1, 3 ], 0 ); + * // returns [ [ [ [ [ 1, 4 ], [ 2, 5 ], [ 3, 6 ] ] ] ] ] + */ + strided2array5d: typeof strided2array5d; + /** * Takes element from an array. * @@ -1699,6 +1969,105 @@ interface Namespace { */ ternary2d: typeof ternary2d; + /** + * Applies a ternary callback to elements in three three-dimensional nested input arrays and assigns results to elements in a three-dimensional nested output array. + * + * ## Notes + * + * - The function assumes that the input and output arrays have the same shape. + * + * @param arrays - array containing three input nested arrays and one output nested array + * @param shape - array shape + * @param fcn - ternary callback + * + * @example + * var ones3d = require( `@stdlib/array/base/ones3d` ); + * var zeros3d = require( `@stdlib/array/base/zeros3d` ); + * + * function add( x, y, z ) { + * return x + y + z; + * } + * + * var shape = [ 1, 2, 2 ]; + * + * var x = ones3d( shape ); + * var y = ones3d( shape ); + * var z = ones3d( shape ); + * var out = zeros3d( shape ); + * + * ns.ternary3d( [ x, y, z, out ], shape, add ); + * + * console.log( out ); + * // => [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] + */ + ternary3d: typeof ternary3d; + + /** + * Applies a ternary callback to elements in three four-dimensional nested input arrays and assigns results to elements in a four-dimensional nested output array. + * + * ## Notes + * + * - The function assumes that the input and output arrays have the same shape. + * + * @param arrays - array containing three input nested arrays and one output nested array + * @param shape - array shape + * @param fcn - ternary callback + * + * @example + * var ones4d = require( `@stdlib/array/base/ones4d` ); + * var zeros4d = require( `@stdlib/array/base/zeros4d` ); + * + * function add( x, y, z ) { + * return x + y + z; + * } + * + * var shape = [ 1, 1, 2, 2 ]; + * + * var x = ones4d( shape ); + * var y = ones4d( shape ); + * var z = ones4d( shape ); + * var out = zeros4d( shape ); + * + * ns.ternary4d( [ x, y, z, out ], shape, add ); + * + * console.log( out ); + * // => [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] + */ + ternary4d: typeof ternary4d; + + /** + * Applies a ternary callback to elements in three five-dimensional nested input arrays and assigns results to elements in a five-dimensional nested output array. + * + * ## Notes + * + * - The function assumes that the input and output arrays have the same shape. + * + * @param arrays - array containing three input nested arrays and one output nested array + * @param shape - array shape + * @param fcn - ternary callback + * + * @example + * var ones5d = require( `@stdlib/array/base/ones5d` ); + * var zeros5d = require( `@stdlib/array/base/zeros5d` ); + * + * function add( x, y, z ) { + * return x + y + z; + * } + * + * var shape = [ 1, 1, 1, 2, 2 ]; + * + * var x = ones5d( shape ); + * var y = ones5d( shape ); + * var z = ones5d( shape ); + * var out = zeros5d( shape ); + * + * ns.ternary5d( [ x, y, z, out ], shape, add ); + * + * console.log( out ); + * // => [ [ [ [ [ 3.0, 3.0 ], [ 3.0, 3.0 ] ] ] ] ] + */ + ternary5d: typeof ternary5d; + /** * Converts an array-like object to a minimal array-like object supporting the accessor protocol. *