You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
* - 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: typeofbroadcastArrays;
377
+
296
378
/**
297
379
* Broadcasts a scalar value to an ndarray having a specified shape.
298
380
*
@@ -854,6 +936,40 @@ interface Namespace {
854
936
*/
855
937
expandDimensions: typeofexpandDimensions;
856
938
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: typeofflag;
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: typeofflags;
972
+
857
973
/**
858
974
* Returns a view of an input ndarray in which the order of elements along the last dimension is reversed.
859
975
*
@@ -1236,6 +1352,71 @@ interface Namespace {
1236
1352
*/
1237
1353
maybeBroadcastArray: typeofmaybeBroadcastArray;
1238
1354
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: typeofmaybeBroadcastArrays;
1419
+
1239
1420
/**
1240
1421
* Defines non-enumerable read-only properties which expose ndarray function meta data.
1241
1422
*
@@ -1583,6 +1764,21 @@ interface Namespace {
1583
1764
*/
1584
1765
numel: typeofnumel;
1585
1766
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: typeofnumelDimension;
1781
+
1586
1782
/**
1587
1783
* Returns the index offset specifying the underlying buffer index of the first iterated ndarray element.
0 commit comments