From 8b71dedc6420933be8c4a2fbf10b5548a6fb6dbf Mon Sep 17 00:00:00 2001 From: stdlib-bot Date: Mon, 16 Dec 2024 03:51:52 +0000 Subject: [PATCH] Auto-generated commit --- CHANGELOG.md | 3 + base/README.md | 15 ++++ base/docs/types/index.d.ts | 155 +++++++++++++++++++++++++++++++++++++ 3 files changed, 173 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 5e3067c3..2b9f37f7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -58,6 +58,7 @@ ##### Features +- [`58e795d`](https://github.com/stdlib-js/stdlib/commit/58e795db467b7bd1d3dc6c5847f91a97fed2ccff) - update namespace TypeScript declarations [(#3937)](https://github.com/stdlib-js/stdlib/pull/3937) - [`14427c7`](https://github.com/stdlib-js/stdlib/commit/14427c79bc62f82b16cbadc9d34749901e48d105) - add `fill`, `map`, and `toReversed` to namespace - [`a0d6619`](https://github.com/stdlib-js/stdlib/commit/a0d66193409576538d0f16aa89cbaeedec7898be) - add `minSignedIntegerDataType` and `minUnsignedIntegerDataType` to namespace - [`8b1548f`](https://github.com/stdlib-js/stdlib/commit/8b1548fb45c1ff131f5edac20cb984344a2d28ec) - update namespace TypeScript declarations [(#3190)](https://github.com/stdlib-js/stdlib/pull/3190) @@ -386,6 +387,8 @@ A total of 3 people contributed to this release. Thank you to the following cont
+- [`58e795d`](https://github.com/stdlib-js/stdlib/commit/58e795db467b7bd1d3dc6c5847f91a97fed2ccff) - **feat:** update namespace TypeScript declarations [(#3937)](https://github.com/stdlib-js/stdlib/pull/3937) _(by stdlib-bot, Philipp Burckhardt)_ +- [`c106b69`](https://github.com/stdlib-js/stdlib/commit/c106b69cc141efc8c32e79d55ad8acf07f3c9c0a) - **docs:** update namespace table of contents [(#3939)](https://github.com/stdlib-js/stdlib/pull/3939) _(by stdlib-bot, Philipp Burckhardt)_ - [`58f02bf`](https://github.com/stdlib-js/stdlib/commit/58f02bf605d6879cd80152f11f913451df2ad494) - **docs:** fix comment _(by Athan Reines)_ - [`baffefb`](https://github.com/stdlib-js/stdlib/commit/baffefb25177147fa3bafa5c1d0562a7528d5054) - **docs:** fix comment _(by Athan Reines)_ - [`0546f39`](https://github.com/stdlib-js/stdlib/commit/0546f395abecb502fd703aa364e758bd733cd18e) - **docs:** disable lint rule _(by Athan Reines)_ diff --git a/base/README.md b/base/README.md index 4d542bfc..7f3b2168 100644 --- a/base/README.md +++ b/base/README.md @@ -72,6 +72,7 @@ var o = ns; - [`emptyLike( x )`][@stdlib/ndarray/base/empty-like]: create an uninitialized ndarray having the same shape and data type as a provided ndarray. - [`empty( dtype, shape, order )`][@stdlib/ndarray/base/empty]: create an uninitialized ndarray having a specified shape and data type. - [`expandDimensions( x, axis )`][@stdlib/ndarray/base/expand-dimensions]: expand the shape of an array by inserting a new dimension of size one at a specified axis. +- [`fill( x, value )`][@stdlib/ndarray/base/fill]: fill an input ndarray with a specified value. - [`flag( x, name )`][@stdlib/ndarray/base/flag]: return a specified flag for a provided ndarray. - [`flags( x, copy )`][@stdlib/ndarray/base/flags]: return the flags of a provided ndarray. - [`fliplr( x, writable )`][@stdlib/ndarray/base/fliplr]: return a view of an input ndarray in which the order of elements along the last dimension is reversed. @@ -81,10 +82,13 @@ var o = ns; - [`ind( idx, max, mode )`][@stdlib/ndarray/base/ind]: return an index given an index mode. - [`ind2sub( shape, strides, offset, order, idx, mode )`][@stdlib/ndarray/base/ind2sub]: convert a linear index to an array of subscripts. - [`iterationOrder( strides )`][@stdlib/ndarray/base/iteration-order]: given a stride array, determine array iteration order. +- [`map( arrays, fcn[, thisArg] )`][@stdlib/ndarray/base/map]: apply a callback function to elements in an input ndarray and assign results to elements in an output ndarray. - [`maxViewBufferIndex( shape, strides, offset )`][@stdlib/ndarray/base/max-view-buffer-index]: compute the maximum linear index in an underlying data buffer accessible to an array view. - [`maybeBroadcastArray( arr, shape )`][@stdlib/ndarray/base/maybe-broadcast-array]: broadcast an ndarray to a specified shape if and only if the specified shape differs from the provided ndarray's shape. - [`maybeBroadcastArrays( arrays )`][@stdlib/ndarray/base/maybe-broadcast-arrays]: broadcast ndarrays to a common shape. - [`metaDataProps( meta, dtypes, obj )`][@stdlib/ndarray/base/meta-data-props]: define non-enumerable read-only properties which expose ndarray function meta data. +- [`minSignedIntegerDataType( value )`][@stdlib/ndarray/base/min-signed-integer-dtype]: determine the minimum ndarray data type for storing a provided signed integer value. +- [`minUnsignedIntegerDataType( value )`][@stdlib/ndarray/base/min-unsigned-integer-dtype]: determine the minimum ndarray data type for storing a provided unsigned integer value. - [`minViewBufferIndex( shape, strides, offset )`][@stdlib/ndarray/base/min-view-buffer-index]: compute the minimum linear index in an underlying data buffer accessible to an array view. - [`minmaxViewBufferIndex( shape, strides, offset )`][@stdlib/ndarray/base/minmax-view-buffer-index]: compute the minimum and maximum linear indices in an underlying data buffer which are accessible to an array view. - [`ndarraylike2ndarray( x )`][@stdlib/ndarray/base/ndarraylike2ndarray]: convert an ndarray-like object to an `ndarray`. @@ -125,6 +129,7 @@ var o = ns; - [`strides2order( strides )`][@stdlib/ndarray/base/strides2order]: determine the order of a multidimensional array based on a provided stride array. - [`sub2ind( shape, strides, offset, ...subscripts, mode )`][@stdlib/ndarray/base/sub2ind]: convert subscripts to a linear index. - [`ndarray2array( buffer, shape, strides, offset, order )`][@stdlib/ndarray/base/to-array]: convert an ndarray buffer to a generic array. +- [`toReversed( x )`][@stdlib/ndarray/base/to-reversed]: return a new ndarray where the order of elements of an input ndarray is reversed along each dimension. - [`transpose( x )`][@stdlib/ndarray/base/transpose]: transpose a matrix (or a stack of matrices). - [`unaryBy( arrays, fcn, clbk[, thisArg] )`][@stdlib/ndarray/base/unary-by]: apply a unary function to each element in an input ndarray according to a callback function and assign results to elements in an output ndarray. - [`unaryLoopOrder( shape, stridesX, stridesY )`][@stdlib/ndarray/base/unary-loop-interchange-order]: reorder ndarray dimensions and associated strides for loop interchange. @@ -249,6 +254,8 @@ console.log( objectKeys( ns ) ); [@stdlib/ndarray/base/expand-dimensions]: https://github.com/stdlib-js/ndarray/tree/main/base/expand-dimensions +[@stdlib/ndarray/base/fill]: https://github.com/stdlib-js/ndarray/tree/main/base/fill + [@stdlib/ndarray/base/flag]: https://github.com/stdlib-js/ndarray/tree/main/base/flag [@stdlib/ndarray/base/flags]: https://github.com/stdlib-js/ndarray/tree/main/base/flags @@ -267,6 +274,8 @@ console.log( objectKeys( ns ) ); [@stdlib/ndarray/base/iteration-order]: https://github.com/stdlib-js/ndarray/tree/main/base/iteration-order +[@stdlib/ndarray/base/map]: https://github.com/stdlib-js/ndarray/tree/main/base/map + [@stdlib/ndarray/base/max-view-buffer-index]: https://github.com/stdlib-js/ndarray/tree/main/base/max-view-buffer-index [@stdlib/ndarray/base/maybe-broadcast-array]: https://github.com/stdlib-js/ndarray/tree/main/base/maybe-broadcast-array @@ -275,6 +284,10 @@ console.log( objectKeys( ns ) ); [@stdlib/ndarray/base/meta-data-props]: https://github.com/stdlib-js/ndarray/tree/main/base/meta-data-props +[@stdlib/ndarray/base/min-signed-integer-dtype]: https://github.com/stdlib-js/ndarray/tree/main/base/min-signed-integer-dtype + +[@stdlib/ndarray/base/min-unsigned-integer-dtype]: https://github.com/stdlib-js/ndarray/tree/main/base/min-unsigned-integer-dtype + [@stdlib/ndarray/base/min-view-buffer-index]: https://github.com/stdlib-js/ndarray/tree/main/base/min-view-buffer-index [@stdlib/ndarray/base/minmax-view-buffer-index]: https://github.com/stdlib-js/ndarray/tree/main/base/minmax-view-buffer-index @@ -355,6 +368,8 @@ console.log( objectKeys( ns ) ); [@stdlib/ndarray/base/to-array]: https://github.com/stdlib-js/ndarray/tree/main/base/to-array +[@stdlib/ndarray/base/to-reversed]: https://github.com/stdlib-js/ndarray/tree/main/base/to-reversed + [@stdlib/ndarray/base/transpose]: https://github.com/stdlib-js/ndarray/tree/main/base/transpose [@stdlib/ndarray/base/unary-by]: https://github.com/stdlib-js/ndarray/tree/main/base/unary-by diff --git a/base/docs/types/index.d.ts b/base/docs/types/index.d.ts index 9a82e659..b19dd8ab 100644 --- a/base/docs/types/index.d.ts +++ b/base/docs/types/index.d.ts @@ -50,6 +50,7 @@ import dtypes2signatures = require( './../../../base/dtypes2signatures' ); import empty = require( './../../../base/empty' ); import emptyLike = require( './../../../base/empty-like' ); import expandDimensions = require( './../../../base/expand-dimensions' ); +import fill = require( './../../../base/fill' ); import flag = require( './../../../base/flag' ); import flags = require( './../../../base/flags' ); import fliplr = require( './../../../base/fliplr' ); @@ -59,10 +60,13 @@ import scalar2ndarray = require( './../../../base/from-scalar' ); import ind = require( './../../../base/ind' ); import ind2sub = require( './../../../base/ind2sub' ); import iterationOrder = require( './../../../base/iteration-order' ); +import map = require( './../../../base/map' ); import maxViewBufferIndex = require( './../../../base/max-view-buffer-index' ); import maybeBroadcastArray = require( './../../../base/maybe-broadcast-array' ); import maybeBroadcastArrays = require( './../../../base/maybe-broadcast-arrays' ); import metaDataProps = require( './../../../base/meta-data-props' ); +import minSignedIntegerDataType = require( './../../../base/min-signed-integer-dtype' ); +import minUnsignedIntegerDataType = require( './../../../base/min-unsigned-integer-dtype' ); import minViewBufferIndex = require( './../../../base/min-view-buffer-index' ); import minmaxViewBufferIndex = require( './../../../base/minmax-view-buffer-index' ); import ndarraylike2ndarray = require( './../../../base/ndarraylike2ndarray' ); @@ -103,6 +107,7 @@ import strides2offset = require( './../../../base/strides2offset' ); import strides2order = require( './../../../base/strides2order' ); import sub2ind = require( './../../../base/sub2ind' ); import ndarray2array = require( './../../../base/to-array' ); +import toReversed = require( './../../../base/to-reversed' ); import transpose = require( './../../../base/transpose' ); import unary = require( './../../../base/unary' ); import unaryBy = require( './../../../base/unary-by' ); @@ -938,6 +943,44 @@ interface Namespace { */ expandDimensions: typeof expandDimensions; + /** + * Fills an input ndarray with a specified value. + * + * @param x - input ndarray + * @param value - scalar value + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * + * // Create a data buffer: + * var xbuf = new Float64Array( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ] ); + * + * // Define the shape of the input array: + * var shape = [ 3, 1, 2 ]; + * + * // Define the array strides: + * var sx = [ 2, 2, 1 ]; + * + * // Define the index offset: + * var ox = 0; + * + * // Create the input ndarray-like object: + * var x = { + * 'dtype': 'float64', + * 'data': xbuf, + * 'shape': shape, + * 'strides': sx, + * 'offset': ox, + * 'order': 'row-major' + * }; + * + * ns.fill( x, 10.0 ); + * + * console.log( x.data ); + * // => [ 10.0, 10.0, 10.0, 10.0, 10.0, 10.0 ] + */ + fill: typeof fill; + /** * Returns a specified flag for a provided ndarray. * @@ -1291,6 +1334,50 @@ interface Namespace { */ iterationOrder: typeof iterationOrder; + /** + * Applies a callback function to the elements in an input ndarray and assigns results to the elements in an output ndarray. + * + * @param arrays - array-like object containing one input ndarray and one output ndarray + * @param fcn - callback function + * @param thisArg - callback function execution context + * @throws arrays must have the same number of dimensions + * @throws arrays must have the same shape + * + * @example + * var Float64Array = require( '@stdlib/array/float64' ); + * var ndarray = require( './../../../ctor' ); + * + * function scale( x ) { + * return x * 10.0; + * } + * + * // Create data buffers: + * 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 ] ); + * var ybuf = new Float64Array( 6 ); + * + * // Define the shape of the input and output arrays: + * var shape = [ 3, 1, 2 ]; + * + * // Define the array strides: + * var sx = [ 4, 4, 1 ]; + * var sy = [ 2, 2, 1 ]; + * + * // Define the index offsets: + * var ox = 1; + * var oy = 0; + * + * // Create the input and output ndarrays: + * var x = ndarray( 'float64', xbuf, shape, sx, ox, 'row-major' ); + * var y = ndarray( 'float64', ybuf, shape, sy, oy, 'row-major' ); + * + * // Apply the ns.map function: + * ns.map( [ x, y ], scale ); + * + * console.log( y.data ); + * // => [ 20.0, 30.0, 60.0, 70.0, 100.0, 110.0 ] + */ + map: typeof map; + /** * Computes the maximum linear index in an underlying data buffer accessible to an array view. * @@ -1484,6 +1571,38 @@ interface Namespace { */ metaDataProps: typeof metaDataProps; + /** + * Returns the minimum ndarray data type for storing a provided signed integer value. + * + * @param value - scalar value + * @returns ndarray data type + * + * @example + * var dt = ns.minSignedIntegerDataType( 1280 ); + * // returns 'int16' + * + * @example + * var dt = ns.minSignedIntegerDataType( 3 ); + * // returns 'int8' + */ + minSignedIntegerDataType: typeof minSignedIntegerDataType; + + /** + * Returns the minimum ndarray data type for storing a provided unsigned integer value. + * + * @param value - scalar value + * @returns ndarray data type + * + * @example + * var dt = ns.minUnsignedIntegerDataType( 1280 ); + * // returns 'uint16' + * + * @example + * var dt = ns.minUnsignedIntegerDataType( 3 ); + * // returns 'uint8' + */ + minUnsignedIntegerDataType: typeof minUnsignedIntegerDataType; + /** * Computes the minimum linear index in an underlying data buffer accessible to an array view. * @@ -2718,6 +2837,42 @@ interface Namespace { */ ndarray2array: typeof ndarray2array; + /** + * Returns a new ndarray where the order of elements of an input ndarray is reversed along each dimension. + * + * @param x - input array + * @returns output array + * + * @example + * var typedarray = require( '@stdlib/array/typed' ); + * var ndarray = require( './../../../ctor' ); + * var ndarray2array = require( './../../../to-array' ); + * + * var buffer = typedarray( [ 1.0, 2.0, 3.0, 4.0, 5.0, 6.0 ], 'float64' ); + * var shape = [ 3, 2 ]; + * var strides = [ 2, 1 ]; + * var offset = 0; + * + * var x = ndarray( 'float64', buffer, shape, strides, offset, 'row-major' ); + * // returns + * + * var sh = x.shape; + * // returns [ 3, 2 ] + * + * var arr = ndarray2array( x ); + * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ], [ 5.0, 6.0 ] ] + * + * var y = ns.toReversed( x ); + * // returns + * + * sh = y.shape; + * // returns [ 3, 2 ] + * + * arr = ndarray2array( y ); + * // returns [ [ 6.0, 5.0 ], [ 4.0, 3.0 ], [ 2.0, 1.0 ] ] + */ + toReversed: typeof toReversed; + /** * Transposes a matrix (or a stack of matrices). *