@stdlib/math-tools 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2024 The Stdlib Authors.
1
+ Copyright (c) 2016-2026 The Stdlib Authors.
package/README.md CHANGED
@@ -68,7 +68,7 @@ The namespace exposes the following functions:
68
68
 
69
69
  <div class="namespace-toc">
70
70
 
71
- - <span class="signature">[`unary( table )`][@stdlib/math/tools/unary]</span><span class="delimiter">: </span><span class="description">multiple dispatch for unary mathematical functions.</span>
71
+ - <span class="signature">[`unary( fcn, idtypes, odtypes, policies )`][@stdlib/math/tools/unary]</span><span class="delimiter">: </span><span class="description">create a function which performs element-wise computation by applying a unary function to each element in an input ndarray.</span>
72
72
 
73
73
  </div>
74
74
 
@@ -131,7 +131,7 @@ See [LICENSE][stdlib-license].
131
131
 
132
132
  ## Copyright
133
133
 
134
- Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
134
+ Copyright &copy; 2016-2026. The Stdlib [Authors][stdlib-authors].
135
135
 
136
136
  </section>
137
137
 
@@ -144,8 +144,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
144
144
  [npm-image]: http://img.shields.io/npm/v/@stdlib/math-tools.svg
145
145
  [npm-url]: https://npmjs.org/package/@stdlib/math-tools
146
146
 
147
- [test-image]: https://github.com/stdlib-js/math-tools/actions/workflows/test.yml/badge.svg?branch=v0.2.1
148
- [test-url]: https://github.com/stdlib-js/math-tools/actions/workflows/test.yml?query=branch:v0.2.1
147
+ [test-image]: https://github.com/stdlib-js/math-tools/actions/workflows/test.yml/badge.svg?branch=v0.3.0
148
+ [test-url]: https://github.com/stdlib-js/math-tools/actions/workflows/test.yml?query=branch:v0.3.0
149
149
 
150
150
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-tools/main.svg
151
151
  [coverage-url]: https://codecov.io/github/stdlib-js/math-tools?branch=main
@@ -157,8 +157,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
157
157
 
158
158
  -->
159
159
 
160
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
161
- [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
160
+ [chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
161
+ [chat-url]: https://stdlib.zulipchat.com
162
162
 
163
163
  [stdlib]: https://github.com/stdlib-js/stdlib
164
164
 
@@ -27,42 +27,50 @@ import unary = require( '@stdlib/math-tools-unary' );
27
27
  */
28
28
  interface Namespace {
29
29
  /**
30
- * Returns a function which dispatches to specified functions based on input argument types.
30
+ * Returns a function which performs element-wise computation.
31
31
  *
32
- * @param table - resolution table object
33
- * @throws must provide valid table fields
34
- * @throws table field values must be array-like objects having an even number of elements
35
- * @throws table field values must consist of dtype-function pairs
36
- * @returns dispatch function
32
+ * @param fcn - function applies a unary function to each element in an ndarray
33
+ * @param idtypes - list containing lists of supported input data types for each ndarray argument
34
+ * @param odtypes - list of supported output data types
35
+ * @param policies - dispatch policies
36
+ * @returns function which performs element-wise computation
37
37
  *
38
38
  * @example
39
- * var nabs = require( '@stdlib/math-base-special-abs' );
40
- * var dabs = require( '@stdlib/math-strided-special-dabs' );
41
- * var sabs = require( '@stdlib/math-strided-special-sabs' );
42
- * var gabs = require( '@stdlib/math-strided-special-abs' );
43
- * var Float64Array = require( '@stdlib/array-float64' );
39
+ * var base = require( '@stdlib/math-base-special-abs' );
40
+ * var dispatch = require( '@stdlib/ndarray-dispatch' );
41
+ * var ndarrayUnary = require( '@stdlib/ndarray-base-unary' );
42
+ * var ndarray2array = require( '@stdlib/ndarray-to-array' );
43
+ * var array = require( '@stdlib/ndarray-array' );
44
44
  *
45
- * var table = {
46
- * 'scalar': [
47
- * 'number', nabs
48
- * ],
49
- * 'array': [
50
- * 'float64', dabs,
51
- * 'float32', sabs,
52
- * 'generic', gabs
53
- * ],
54
- * 'ndarray': [
55
- * 'float64', dabs.ndarray,
56
- * 'float32', sabs.ndarray,
57
- * 'generic', gabs.ndarray
58
- * ]
45
+ * var types = [
46
+ * 'float64', 'float64',
47
+ * 'float32', 'float32',
48
+ * 'generic', 'generic'
49
+ * ];
50
+ * var data = [
51
+ * base,
52
+ * base,
53
+ * base
54
+ * ];
55
+ * var dispatcher = dispatch( ndarrayUnary, types, data, 2, 1, 1 );
56
+ *
57
+ * var idt = [ 'float64', 'float32', 'generic' ];
58
+ * var odt = idt;
59
+ *
60
+ * var policies = {
61
+ * 'output': 'real_and_generic',
62
+ * 'casting': 'none'
59
63
  * };
64
+ * var abs = ns.unary( dispatcher, [ idt ], odt, policies );
60
65
  *
61
- * var abs = ns.unary( table );
66
+ * var x = array( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
67
+ * // returns <ndarray>
62
68
  *
63
- * var x = new Float64Array( [ -1.0, -2.0, -3.0 ] );
64
69
  * var y = abs( x );
65
- * // returns <Float64Array>[ 1.0, 2.0, 3.0 ]
70
+ * // returns <ndarray>
71
+ *
72
+ * var arr = ndarray2array( y );
73
+ * // returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
66
74
  */
67
75
  unary: typeof unary;
68
76
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-tools",
3
- "version": "0.2.1",
3
+ "version": "0.3.0",
4
4
  "description": "Math tools.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -30,8 +30,8 @@
30
30
  "url": "https://github.com/stdlib-js/stdlib/issues"
31
31
  },
32
32
  "dependencies": {
33
- "@stdlib/math-tools-unary": "^0.2.1",
34
- "@stdlib/utils-define-read-only-property": "^0.2.1"
33
+ "@stdlib/math-tools-unary": "^0.2.2",
34
+ "@stdlib/utils-define-read-only-property": "^0.2.2"
35
35
  },
36
36
  "devDependencies": {},
37
37
  "engines": {