@@ -50,6 +50,7 @@ import dtypes2signatures = require( '@stdlib/ndarray/base/dtypes2signatures' );
50
50
import empty = require( '@stdlib/ndarray/base/empty' ) ;
51
51
import emptyLike = require( '@stdlib/ndarray/base/empty-like' ) ;
52
52
import expandDimensions = require( '@stdlib/ndarray/base/expand-dimensions' ) ;
53
+ import fill = require( '@stdlib/ndarray/base/fill' ) ;
53
54
import flag = require( '@stdlib/ndarray/base/flag' ) ;
54
55
import flags = require( '@stdlib/ndarray/base/flags' ) ;
55
56
import fliplr = require( '@stdlib/ndarray/base/fliplr' ) ;
@@ -59,10 +60,13 @@ import scalar2ndarray = require( '@stdlib/ndarray/base/from-scalar' );
59
60
import ind = require( '@stdlib/ndarray/base/ind' ) ;
60
61
import ind2sub = require( '@stdlib/ndarray/base/ind2sub' ) ;
61
62
import iterationOrder = require( '@stdlib/ndarray/base/iteration-order' ) ;
63
+ import map = require( '@stdlib/ndarray/base/map' ) ;
62
64
import maxViewBufferIndex = require( '@stdlib/ndarray/base/max-view-buffer-index' ) ;
63
65
import maybeBroadcastArray = require( '@stdlib/ndarray/base/maybe-broadcast-array' ) ;
64
66
import maybeBroadcastArrays = require( '@stdlib/ndarray/base/maybe-broadcast-arrays' ) ;
65
67
import metaDataProps = require( '@stdlib/ndarray/base/meta-data-props' ) ;
68
+ import minSignedIntegerDataType = require( '@stdlib/ndarray/base/min-signed-integer-dtype' ) ;
69
+ import minUnsignedIntegerDataType = require( '@stdlib/ndarray/base/min-unsigned-integer-dtype' ) ;
66
70
import minViewBufferIndex = require( '@stdlib/ndarray/base/min-view-buffer-index' ) ;
67
71
import minmaxViewBufferIndex = require( '@stdlib/ndarray/base/minmax-view-buffer-index' ) ;
68
72
import ndarraylike2ndarray = require( '@stdlib/ndarray/base/ndarraylike2ndarray' ) ;
@@ -103,6 +107,7 @@ import strides2offset = require( '@stdlib/ndarray/base/strides2offset' );
103
107
import strides2order = require( '@stdlib/ndarray/base/strides2order' ) ;
104
108
import sub2ind = require( '@stdlib/ndarray/base/sub2ind' ) ;
105
109
import ndarray2array = require( '@stdlib/ndarray/base/to-array' ) ;
110
+ import toReversed = require( '@stdlib/ndarray/base/to-reversed' ) ;
106
111
import transpose = require( '@stdlib/ndarray/base/transpose' ) ;
107
112
import unary = require( '@stdlib/ndarray/base/unary' ) ;
108
113
import unaryBy = require( '@stdlib/ndarray/base/unary-by' ) ;
@@ -938,6 +943,44 @@ interface Namespace {
938
943
*/
939
944
expandDimensions : typeof expandDimensions ;
940
945
946
+ /**
947
+ * Fills an input ndarray with a specified value.
948
+ *
949
+ * @param x - input ndarray
950
+ * @param value - scalar value
951
+ *
952
+ * @example
953
+ * var Float64Array = require( '@stdlib/array/float64' );
954
+ *
955
+ * // Create a data buffer:
956
+ * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] );
957
+ *
958
+ * // Define the shape of the input array:
959
+ * var shape = [ 3, 1, 2 ];
960
+ *
961
+ * // Define the array strides:
962
+ * var sx = [ 2, 2, 1 ];
963
+ *
964
+ * // Define the index offset:
965
+ * var ox = 0;
966
+ *
967
+ * // Create the input ndarray-like object:
968
+ * var x = {
969
+ * 'dtype': 'float64',
970
+ * 'data': xbuf,
971
+ * 'shape': shape,
972
+ * 'strides': sx,
973
+ * 'offset': ox,
974
+ * 'order': 'row-major'
975
+ * };
976
+ *
977
+ * ns.fill( x, 10.0 );
978
+ *
979
+ * console.log( x.data );
980
+ * // => <Float64Array>[ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ]
981
+ */
982
+ fill : typeof fill ;
983
+
941
984
/**
942
985
* Returns a specified flag for a provided ndarray.
943
986
*
@@ -1291,6 +1334,50 @@ interface Namespace {
1291
1334
*/
1292
1335
iterationOrder : typeof iterationOrder ;
1293
1336
1337
+ /**
1338
+ * Applies a callback function to the elements in an input ndarray and assigns results to the elements in an output ndarray.
1339
+ *
1340
+ * @param arrays - array-like object containing one input ndarray and one output ndarray
1341
+ * @param fcn - callback function
1342
+ * @param thisArg - callback function execution context
1343
+ * @throws arrays must have the same number of dimensions
1344
+ * @throws arrays must have the same shape
1345
+ *
1346
+ * @example
1347
+ * var Float64Array = require( '@stdlib/array/float64' );
1348
+ * var ndarray = require( '@stdlib/ndarray/ctor' );
1349
+ *
1350
+ * function scale( x ) {
1351
+ * return x * 10.0;
1352
+ * }
1353
+ *
1354
+ * // Create data buffers:
1355
+ * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0, 7.0, 8.0, 9.0, 10.0, 11.0, 12.0 ] );
1356
+ * var ybuf = new Float64Array( 6 );
1357
+ *
1358
+ * // Define the shape of the input and output arrays:
1359
+ * var shape = [ 3, 1, 2 ];
1360
+ *
1361
+ * // Define the array strides:
1362
+ * var sx = [ 4, 4, 1 ];
1363
+ * var sy = [ 2, 2, 1 ];
1364
+ *
1365
+ * // Define the index offsets:
1366
+ * var ox = 1;
1367
+ * var oy = 0;
1368
+ *
1369
+ * // Create the input and output ndarrays:
1370
+ * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' );
1371
+ * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' );
1372
+ *
1373
+ * // Apply the ns.map function:
1374
+ * ns.map( [ x, y ], scale );
1375
+ *
1376
+ * console.log( y.data );
1377
+ * // => <Float64Array>[ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ]
1378
+ */
1379
+ map : typeof map ;
1380
+
1294
1381
/**
1295
1382
* Computes the maximum linear index in an underlying data buffer accessible to an array view.
1296
1383
*
@@ -1484,6 +1571,38 @@ interface Namespace {
1484
1571
*/
1485
1572
metaDataProps : typeof metaDataProps ;
1486
1573
1574
+ /**
1575
+ * Returns the minimum ndarray data type for storing a provided signed integer value.
1576
+ *
1577
+ * @param value - scalar value
1578
+ * @returns ndarray data type
1579
+ *
1580
+ * @example
1581
+ * var dt = ns.minSignedIntegerDataType( 1280 );
1582
+ * // returns 'int16'
1583
+ *
1584
+ * @example
1585
+ * var dt = ns.minSignedIntegerDataType( 3 );
1586
+ * // returns 'int8'
1587
+ */
1588
+ minSignedIntegerDataType : typeof minSignedIntegerDataType ;
1589
+
1590
+ /**
1591
+ * Returns the minimum ndarray data type for storing a provided unsigned integer value.
1592
+ *
1593
+ * @param value - scalar value
1594
+ * @returns ndarray data type
1595
+ *
1596
+ * @example
1597
+ * var dt = ns.minUnsignedIntegerDataType( 1280 );
1598
+ * // returns 'uint16'
1599
+ *
1600
+ * @example
1601
+ * var dt = ns.minUnsignedIntegerDataType( 3 );
1602
+ * // returns 'uint8'
1603
+ */
1604
+ minUnsignedIntegerDataType : typeof minUnsignedIntegerDataType ;
1605
+
1487
1606
/**
1488
1607
* Computes the minimum linear index in an underlying data buffer accessible to an array view.
1489
1608
*
@@ -2718,6 +2837,42 @@ interface Namespace {
2718
2837
*/
2719
2838
ndarray2array : typeof ndarray2array ;
2720
2839
2840
+ /**
2841
+ * Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension.
2842
+ *
2843
+ * @param x - input array
2844
+ * @returns output array
2845
+ *
2846
+ * @example
2847
+ * var typedarray = require( '@stdlib/array/typed' );
2848
+ * var ndarray = require( '@stdlib/ndarray/ctor' );
2849
+ * var ndarray2array = require( '@stdlib/ndarray/to-array' );
2850
+ *
2851
+ * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' );
2852
+ * var shape = [ 3, 2 ];
2853
+ * var strides = [ 2, 1 ];
2854
+ * var offset = 0;
2855
+ *
2856
+ * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' );
2857
+ * // returns <ndarray>
2858
+ *
2859
+ * var sh = x.shape;
2860
+ * // returns [ 3, 2 ]
2861
+ *
2862
+ * var arr = ndarray2array( x );
2863
+ * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ]
2864
+ *
2865
+ * var y = ns.toReversed( x );
2866
+ * // returns <ndarray>
2867
+ *
2868
+ * sh = y.shape;
2869
+ * // returns [ 3, 2 ]
2870
+ *
2871
+ * arr = ndarray2array( y );
2872
+ * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ]
2873
+ */
2874
+ toReversed : typeof toReversed ;
2875
+
2721
2876
/**
2722
2877
* Transposes a matrix (or a stack of matrices).
2723
2878
*
0 commit comments