8000 Auto-generated commit · stdlib-js/ndarray-base@4e2253f · GitHub
[go: up one dir, main page]

Skip to content

Commit 4e2253f

Browse files
committed
Auto-generated commit
1 parent c76e1df commit 4e2253f

File tree

2 files changed

+197
-1
lines changed

2 files changed

+197
-1
lines changed

NOTICE

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
Copyright (c) 2016-2023 The Stdlib Authors.
1+
Copyright (c) 2016-2024 The Stdlib Authors.

docs/types/index.d.ts

Lines changed: 196 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,6 +26,7 @@ import binaryLoopOrder = require( '@stdlib/ndarray-base-binary-loop-interchange-
2626
import binaryBlockSize = require( '@stdlib/ndarray-base-binary-tiling-block-size' );
2727
import bind2vind = require( '@stdlib/ndarray-base-bind2vind' );
2828
import broadcastArray = require( '@stdlib/ndarray-base-broadcast-array' );
29+
import broadcastArrays = require( '@stdlib/ndarray-base-broadcast-arrays' );
2930
import broadcastScalar = require( '@stdlib/ndarray-base-broadcast-scalar' );
3031
import broadcastShapes = require( '@stdlib/ndarray-base-broadcast-shapes' );
3132
import buffer = require( '@stdlib/ndarray-base-buffer' );
@@ -49,6 +50,8 @@ import dtypes2signatures = require( '@stdlib/ndarray-base-dtypes2signatures' );
4950
import empty = require( '@stdlib/ndarray-base-empty' );
5051
import emptyLike = require( '@stdlib/ndarray-base-empty-like' );
5152
import expandDimensions = require( '@stdlib/ndarray-base-expand-dimensions' );
53+
import flag = require( '@stdlib/ndarray-base-flag' );
54+
import flags = require( '@stdlib/ndarray-base-flags' );
5255
import fliplr = require( '@stdlib/ndarray-base-fliplr' );
5356
import flipud = require( '@stdlib/ndarray-base-flipud' );
5457
import 10000 scalar2ndarray = require( '@stdlib/ndarray-base-from-scalar' );
@@ -57,6 +60,7 @@ import ind2sub = require( '@stdlib/ndarray-base-ind2sub' );
5760
import iterationOrder = require( '@stdlib/ndarray-base-iteration-order' );
5861
import maxViewBufferIndex = require( '@stdlib/ndarray-base-max-view-buffer-index' );
5962
import maybeBroadcastArray = require( '@stdlib/ndarray-base-maybe-broadcast-array' );
63+
import maybeBroadcastArrays = require( '@stdlib/ndarray-base-maybe-broadcast-arrays' );
6064
import metaDataProps = require( '@stdlib/ndarray-base-meta-data-props' );
6165
import minViewBufferIndex = require( '@stdlib/ndarray-base-min-view-buffer-index' );
6266
import minmaxViewBufferIndex = require( '@stdlib/ndarray-base-minmax-view-buffer-index' );
@@ -69,6 +73,7 @@ import nullary = require( '@stdlib/ndarray-base-nullary' );
6973
import nullaryLoopOrder = require( '@stdlib/ndarray-base-nullary-loop-interchange-order' );
7074
import nullaryBlockSize = require( '@stdlib/ndarray-base-nullary-tiling-block-size' );
7175
import numel = require( '@stdlib/ndarray-base-numel' );
76+
import numelDimension = require( '@stdlib/ndarray-base-numel-dimension' );
7277
import offset = require( '@stdlib/ndarray-base-offset' );
7378
import order = require( '@stdlib/ndarray-base-order' );
7479
import outputPolicyEnum2Str = require( '@stdlib/ndarray-base-output-policy-enum2str' );
@@ -293,6 +298,83 @@ interface Namespace {
293298
*/
294299
broadcastArray: typeof broadcastArray;
295300

301+
/**
302+
* Broadcasts ndarrays to a common shape.
303+
*
304+
* ## Notes
305+
*
306+
* - The function throws an error if provided broadcast-incompatible ndarrays.
307+
* - The returned arrays are views on their respective underlying array data buffers. The views are typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to a view may affect multiple elements. If you need to write to a returned array, copy the array before performing operations which may mutate elements.
308+
* - The returned arrays are "base" ndarrays, and, thus, returned arrays do not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast ndarray-like objects within internal implementations and to do so with minimal overhead.
309+
* - The function always returns new ndarray instances even if an input ndarray shape and the broadcasted shape are the same.
310+
*
311+
* @param arrays - input arrays
312+
* @throws input arrays must be broadcast compatible
313+
* @returns list of broadcasted arrays
314+
*
315+
* @example
316+
* var array = require( '@stdlib/ndarray-array' );
317+
* var zeros = require( '@stdlib/ndarray-zeros' );
318+
*
319+
* var x1 = array( [ [ 1, 2 ], [ 3, 4 ] ] );
320+
* // returns <ndarray>
321+
*
322+
* var shx = x1.shape;
323+
* // returns [ 2, 2 ]
324+
*
325+
* var y1 = zeros( [ 3, 2, 2 ] );
326+
* // returns <ndarray>
327+
*
328+
* var shy = y1.shape;
329+
* // returns [ 3, 2, 2 ]
330+
*
331+
* var out = ns.broadcastArrays( [ x1, y1 ] );
332+
* // returns <ndarray>
333+
*
334+
* var x2 = out[ 0 ];
335+
* // returns <ndarray>
336+
*
337+
* var y2 = out[ 1 ];
338+
* // returns <ndarray>
339+
*
340+
* shx = x2.shape;
341+
* // returns [ 3, 2, 2 ]
342+
*
343+
* shy = y2.shape;
344+
* // returns [ 3, 2, 2 ]
345+
*
346+
* var v = x2.get( 0, 0, 0 );
347+
* // returns 1
348+
*
349+
* v = x2.get( 0, 0, 1 );
350+
* // returns 2
351+
*
352+
* v = x2.get( 1, 0, 0 );
353+
* // returns 1
354+
*
355+
* v = x2.get( 1, 1, 0 );
356+
* // returns 3
357+
*
358+
* v = x2.get( 2, 0, 0 );
359+
* // returns 1
360+
*
361+
* v = x2.get( 2, 1, 1 );
362+
* // returns 4
363+
*
364+
* @example
365+
* var zeros = require( '@stdlib/ndarray-zeros' );
366+
*
367+
* var x = zeros( [ 2, 2 ] );
368+
* // returns <ndarray>
369+
*
370+
* var y = zeros( [ 4, 2 ] );
371+
* // returns <ndarray>
372+
*
373+
* var out = ns.broadcastArrays( [ x, y ] );
374+
* // throws <Error>
375+
*/
376+
broadcastArrays: typeof broadcastArrays;
377+
296378
/**
297379
* Broadcasts a scalar value to an ndarray having a specified shape.
298380
*
@@ -854,6 +936,40 @@ interface Namespace {
854936
*/
855937
expandDimensions: typeof expandDimensions;
856938

939+
/**
940+
* Returns a specified flag for a provided ndarray.
941+
*
942+
* @param x - input ndarray
943+
* @param name - flag name
944+
* @returns flag value
945+
*
946+
* @example
947+
* var zeros = require( '@stdlib/ndarray-zeros' );
948+
*
949+
* var o = ns.flag( zeros( [ 3, 3, 3 ] ), 'READONLY' );
950+
* // returns <boolean>
951+
*/
952+
flag: typeof flag;
953+
954+
/**
955+
* Returns the flags of a provided ndarray.
956+
*
957+
* ## Notes
958+
*
959+
* - When `copy` is `false`, changes to the returned object may mutate the input ndarray flags. If there is a chance that the returned object will be mutated (either directly or by downstream consumers), set `copy` to `true` to prevent unintended side effects.
960+
*
961+
* @param x - input ndarray
962+
* @param copy - boolean indicating whether to explicitly copy the value assigned to the input ndarray's `flags` property
963+
* @returns flags
964+
*
965+
* @example
966+
* var zeros = require( '@stdlib/ndarray-zeros' );
967+
*
968+
* var o = ns.flags( zeros( [ 3, 3, 3 ] ), false );
969+
* // returns {...}
970+
*/
971+
flags: typeof flags;
972+
857973
/**
858974
* Returns a view of an input ndarray in which the order of elements along the last dimension is reversed.
859975
*
@@ -1236,6 +1352,71 @@ interface Namespace {
12361352
*/
12371353
maybeBroadcastArray: typeof maybeBroadcastArray;
12381354

1355+
/**
1356+
* Broadcasts ndarrays to a common shape.
1357+
*
1358+
* ## Notes
1359+
*
1360+
* - The function throws an error if a provided broadcast-incompatible ndarrays.
1361+
* - If a provided ndarray has a shape matching the common shape, the function returns the provided ndarray.
1362+
* - If a provided ndarray has a different (broadcast compatible) shape than the common shape, the function returns a new (base) ndarray view of the provided ndarray's data. The view is typically **not** contiguous. As more than one element of a returned view may refer to the same memory location, writing to a view may affect multiple elements. If you need to write to a returned array, copy the array before performing operations which may mutate elements.
1363+
* - A returned array view is a "base" ndarray, and, thus, a returned array view does not perform bounds checking or afford any of the guarantees of the non-base ndarray constructor. The primary intent of this function is to broadcast ndarray-like objects within internal implementations and to do so with minimal overhead.
1364+
*
1365+
* @param arrays - input arrays
1366+
* @throws input arrays must be broadcast compatible
1367+
* @returns list of broadcasted arrays
1368+
*
1369+
* @example
1370+
* var array = require( '@stdlib/ndarray-array' );
1371+
* var zeros = require( '@stdlib/ndarray-zeros' );
1372+
*
1373+
* var x = array( [ [ 1, 2 ], [ 3, 4 ] ] );
1374+
* // returns <ndarray>
1375+
*
1376+
* var shx = x.shape;
1377+
* // returns [ 2, 2 ]
1378+
*
1379+
* var y1 = zeros( [ 3, 2, 2 ] );
1380+
* // returns <ndarray>
1381+
*
1382+
* var shy = y1.shape;
1383+
* // returns [ 3, 2, 2 ]
1384+
*
1385+
* var out = ns.maybeBroadcastArrays( [ x, y ] );
1386+
* // returns <ndarray>
1387+
*
1388+
* var x2 = out[ 0 ];
1389+
* // returns <ndarray>
1390+
*
1391+
* var y2 = out[ 1 ];
1392+
* // returns <ndarray>
1393+
*
1394+
* shx = x2.shape;
1395+
* // returns [ 3, 2, 2 ]
1396+
*
1397+
* shy = y2.shape;
1398+
* // returns [ 3, 2, 2 ]
1399+
*
1400+
* var v = x2.get( 0, 0, 0 );
1401+
* // returns 1
1402+
*
1403+
* v = x2.get( 0, 0, 1 );
1404+
* // returns 2
1405+
*
1406+
* v = x2.get( 1, 0, 0 );
1407+
* // returns 1
1408+
*
1409+
* v = x2.get( 1, 1, 0 );
1410+
* // returns 3
1411+
*
1412+
* v = x2.get( 2, 0, 0 );
1413+
* // returns 1
1414+
*
1415+
* v = x2.get( 2, 1, 1 );
1416+
* // returns 4
1417+
*/
1418+
maybeBroadcastArrays: typeof maybeBroadcastArrays;
1419+
12391420
/**
12401421
* Defines non-enumerable read-only properties which expose ndarray function meta data.
12411422
*
@@ -1583,6 +1764,21 @@ interface Namespace {
15831764
*/
15841765
numel: typeof numel;
15851766

1767+
/**
1768+
* Returns the size (i.e., number of elements) of a specified dimension for a provided ndarray.
1769+
*
1770+
* @param x - input ndarray
1771+
* @param dim - dimension index
1772+
* @returns dimension size
1773+
*
1774+
* @example
1775+
* var zeros = require( '@stdlib/ndarray-zeros' );
1776+
*
1777+
* var d = ns.numelDimension( zeros( [ 4, 2, 3 ] ), 0 );
1778+
* // returns 4
1779+
*/
1780+
numelDimension: typeof numelDimension;
1781+
15861782
/**
15871783
* Returns the index offset specifying the underlying buffer index of the first iterated ndarray element.
15881784
*

0 commit comments

Comments
 (0)
0