Skip to content

Commit 3a95753

Browse files
committed
Auto-generated commit
1 parent d908b1d commit 3a95753

File tree

2 files changed

+146
-1
lines changed

2 files changed

+146
-1
lines changed

CHANGELOG.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@
1010

1111
### Features
1212

13+
- [`709563c`](https://github.com/stdlib-js/stdlib/commit/709563c0d7337b5c0632d1988fb263cf39305f86) - update `ndarray/base` TypeScript declarations [(#9716)](https://github.com/stdlib-js/stdlib/pull/9716)
1314
- [`f738a37`](https://github.com/stdlib-js/stdlib/commit/f738a37c1cc32a740c7ecc4cbc7982eca26f67d2) - add `ternaryBlockSize` to namespace
1415
- [`b490370`](https://github.com/stdlib-js/stdlib/commit/b49037059ac498f7e864cb83f0cf59b3feb3b459) - add `ternaryLoopOrder` to namespace
1516
- [`88e4096`](https://github.com/stdlib-js/stdlib/commit/88e4096e8e5941fecc15ef2fd2d5b27e91d69233) - add `ternary` to namespace
@@ -708,6 +709,7 @@ A total of 40 issues were closed in this release:
708709

709710
<details>
710711

712+
- [`709563c`](https://github.com/stdlib-js/stdlib/commit/709563c0d7337b5c0632d1988fb263cf39305f86) - **feat:** update `ndarray/base` TypeScript declarations [(#9716)](https://github.com/stdlib-js/stdlib/pull/9716) _(by stdlib-bot)_
711713
- [`6aee8e2`](https://github.com/stdlib-js/stdlib/commit/6aee8e232a2cebd57d5246d76ffe08e67941c0a4) - **docs:** move content to notes _(by Athan Reines)_
712714
- [`93e0c79`](https://github.com/stdlib-js/stdlib/commit/93e0c79faa246da751b6d7a640b5133fefad00f2) - **refactor:** return the input ndarray and update examples _(by Athan Reines)_
713715
- [`d5ddfc7`](https://github.com/stdlib-js/stdlib/commit/d5ddfc76b9363a57791e018c8435c33dd18a9bee) - **style:** remove empty line _(by Athan Reines)_

base/docs/types/index.d.ts

Lines changed: 144 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,6 +147,10 @@ import strides = require( './../../../base/strides' );
147147
import strides2offset = require( './../../../base/strides2offset' );
148148
import strides2order = require( './../../../base/strides2order' );
149149
import sub2ind = require( './../../../base/sub2ind' );
150+
import ternary = require( './../../../base/ternary' );
151+
import ternaryLoopOrder = require( './../../../base/ternary-loop-interchange-order' );
152+
import ternaryOutputDataType = require( './../../../base/ternary-output-dtype' );
153+
import ternaryBlockSize = require( './../../../base/ternary-tiling-block-size' );
150154
import ndarray2array = require( './../../../base/to-array' );
151155
import toFlippedlr = require( './../../../base/to-flippedlr' );
152156
import toFlippedud = require( './../../../base/to-flippedud' );
@@ -1644,6 +1648,7 @@ interface Namespace {
16441648
* @param x - input ndarray
16451649
* @param fcn - callback function
16461650
* @param thisArg - callback function execution context
1651+
* @returns input ndarray
16471652
*
16481653
* @example
16491654
* var Float64Array = require( '@stdlib/array/float64' );
@@ -1674,10 +1679,13 @@ interface Namespace {
16741679
* 'order': 'row-major'
16751680
* };
16761681
*
1677-
* ns.fillBy( x, fcn );
1682+
* var out = ns.fillBy( x, fcn );
16781683
*
16791684
* console.log( x.data );
16801685
* // => <Float64Array>[ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
1686+
*
1687+
* var bool = ( out === x );
1688+
* // returns true
16811689
*/
16821690
fillBy: typeof fillBy;
16831691

@@ -4073,6 +4081,141 @@ interface Namespace {
40734081
*/
40744082
sub2ind: typeof sub2ind;
40754083

4084+
/**
4085+
* Applies a ternary callback to elements in input ndarrays and assigns results to elements in an output ndarray.
4086+
*
4087+
* @param arrays - array-like object containing three input ndarrays and one output ndarray
4088+
* @param fcn - ternary callback
4089+
* @throws arrays must have the same number of dimensions
4090+
* @throws arrays must have the same shape
4091+
*
4092+
* @example
4093+
* var Float64Array = require( '@stdlib/array/float64' );
4094+
* var ndarray = require( './../../../ctor' );
4095+
* var getData = require( './../../../data-buffer' );
4096+
* var add3 = require( '@stdlib/number/float64/base/add3' );
4097+
*
4098+
* // Create data buffers:
4099+
* var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
4100+
* var ybuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
4101+
* var zbuf = new Float64Array( [ 0.5, 0.5, 0.5, 0.5, 0.5, 0.5 ] );
4102+
* var wbuf = new Float64Array( 6 );
4103+
*
4104+
* // Define the shape of the input and output arrays:
4105+
* var shape = [ 3, 1, 2 ];
4106+
*
4107+
* // Define the array strides:
4108+
* var sx = [ 2, 2, 1 ];
4109+
* var sy = [ 2, 2, 1 ];
4110+
* var sz = [ 2, 2, 1 ];
4111+
* var sw = [ 2, 2, 1 ];
4112+
*
4113+
* // Define the index offsets:
4114+
* var ox = 0;
4115+
* var oy = 0;
4116+
* var oz = 0;
4117+
* var ow = 0;
4118+
*
4119+
* // Create the input and output ndarrays:
4120+
* var x = new ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );
4121+
* var y = new ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' );
4122+
* var z = new ndarray( 'float64', zbuf, shape, sz, oz, 'row-major' );
4123+
* var w = new ndarray( 'float64', wbuf, shape, sw, ow, 'row-major' );
4124+
*
4125+
* // Apply the ns.ternary function:
4126+
* ns.ternary( [ x, y, z, w ], add3 );
4127+
*
4128+
* console.log( getData( w ) );
4129+
* // => <Float64Array>[ 2.5, 4.5, 6.5, 8.5, 10.5, 12.5 ]
4130+
*/
4131+
ternary: typeof ternary;
4132+
4133+
/**
4134+
* Reorders ndarray dimensions and associated strides for loop interchange.
4135+
*
4136+
* ## Notes
4137+
*
4138+
* - The returned object has the following properties:
4139+
*
4140+
* - **sh**: dimensions sorted in loop order.
4141+
* - **sx**: first input ndarray strides sorted in loop order.
4142+
* - **sy**: second input ndarray strides sorted in loop order.
4143+
* - **sz**: third input ndarray strides sorted in loop order.
4144+
* - **sw**: output ndarray strides sorted in loop order.
4145+
*
4146+
* - When iterating over the elements of a multi-dimensional array, accessing elements which are closer in memory can improve performance. To this end, loop interchange is a technique used in loop nest optimization to improve locality of reference and take advantage of CPU cache.
4147+
*
4148+
* The purpose of this function is to order ndarray dimensions according to the magnitude of array strides. By using the ordered dimensions and associated strides, one can construct nested loops (one for each dimension) such that the innermost loop iterates over the dimension in which array elements are closest in memory and the outermost loop iterates over the dimension in which array elements are farthest apart in memory. As a consequence, element iteration is optimized to minimize cache misses and ensure locality of reference.
4149+
*
4150+
* - Cache performance may be degraded if the layout order (i.e., row-major or column-major) differs for the input and output ndarrays. This function is intended to optimize cache performance for the most common layout order. Accordingly, if the output ndarray has a different layout order (e.g., if the input ndarrays are row-major and the output ndarray is column-major), cache misses are likely for the output ndarray. In general, to ensure best performance, input and output ndarrays should have the same layout order.
4151+
*
4152+
* - The function assumes that the input and output ndarrays have the same shape. Hence, loop interchange order should only be determined **after** broadcasting.
4153+
*
4154+
* @param shape - array dimensions
4155+
* @param stridesX - first input array stride lengths
4156+
* @param stridesY - second input array stride lengths
4157+
* @param stridesZ - third input array stride lengths
4158+
* @param stridesW - output array stride lengths
4159+
* @returns loop interchange data
4160+
*
4161+
* @example
4162+
* var sh = [ 2, 3, 4 ];
4163+
*
4164+
* var sx = [ 12, 4, 1 ]; // row-major
4165+
* var sy = [ 24, 8, 1 ]; // row-major
4166+
* var sz = [ 1, 4, 12 ]; // column-major
4167+
* var sw = [ 1, -2, 6 ]; // column-major
4168+
*
4169+
* var o = ns.ternaryLoopOrder( sh, sx, sy, sz, sw );
4170+
* // returns {...}
4171+
*
4172+
* var ssh = o.sh;
4173+
* // returns [ 2, 3, 4 ]
4174+
*
4175+
* var ssx = o.sx;
4176+
* // returns [ 12, 4, 1 ]
4177+
*
4178+
* var ssy = o.sy;
4179+
* // returns [ 24, 8, 1 ]
4180+
*
4181+
* var ssz = o.sz;
4182+
* // returns [ 1, 4, 12 ]
4183+
*
4184+
* var ssw = o.sw;
4185+
* // returns [ 1, -2, 6 ]
4186+
*/
4187+
ternaryLoopOrder: typeof ternaryLoopOrder;
4188+
4189+
/**
4190+
* Resolves the output ndarray data type for a ternary function.
4191+
*
4192+
* @param xdtype - first input ndarray data type
4193+
* @param ydtype - second input ndarray data type
4194+
* @param zdtype - third input ndarray data type
4195+
* @param policy - output ndarray data type policy
4196+
* @returns output ndarray data type
4197+
*
4198+
* @example
4199+
* var dt = ns.ternaryOutputDataType( 'float64', 'float32', 'float32', 'complex_floating_point' );
4200+
* // returns <DataType>
4201+
*/
4202+
ternaryOutputDataType: typeof ternaryOutputDataType;
4203+
4204+
/**
4205+
* Returns a loop block size for multi-dimensional array tiled loops.
4206+
*
4207+
* @param dtypeX - first input array data type
4208+
* @param dtypeY - second input array data type
4209+
* @param dtypeZ - third input array data type
4210+
* @param dtypeW - output array data type
4211+
* @returns block size (in units of elements)
4212+
*
4213+
* @example
4214+
* var bsize = ns.ternaryBlockSize( 'float64', 'float64', 'float64', 'float64' );
4215+
* // returns <number>
4216+
*/
4217+
ternaryBlockSize: typeof ternaryBlockSize;
4218+
40764219
/**
40774220
* Converts an ndarray buffer to a generic array (which may include nested arrays).
40784221
*

0 commit comments

Comments
 (0)