@stdlib/math-tools-unary 0.2.2 → 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 +1 -1
- package/README.md +220 -189
- package/dist/index.d.ts +2 -2
- package/dist/index.js +6 -18
- package/dist/index.js.map +4 -4
- package/docs/types/index.d.ts +80 -166
- package/lib/index.js +19 -14
- package/lib/main.js +153 -149
- package/lib/validate.js +13 -15
- package/package.json +21 -17
- package/lib/defaults.json +0 -3
- package/lib/ndarray.js +0 -63
- package/lib/policies.json +0 -6
- package/lib/resolve_output_dtype.js +0 -78
- package/lib/validate_options.js +0 -67
- package/lib/validate_table.js +0 -84
package/NOTICE
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
Copyright (c) 2016-
|
|
1
|
+
Copyright (c) 2016-2026 The Stdlib Authors.
|
package/README.md
CHANGED
|
@@ -33,12 +33,18 @@ limitations under the License.
|
|
|
33
33
|
|
|
34
34
|
[![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
|
|
35
35
|
|
|
36
|
-
>
|
|
36
|
+
> Create a function which performs element-wise computation by applying a unary function to each element in an input ndarray.
|
|
37
37
|
|
|
38
38
|
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
|
|
39
39
|
|
|
40
40
|
<section class="intro">
|
|
41
41
|
|
|
42
|
+
The purpose of this package is to provide a thin wrapper around a lower-level interface supporting multiple dispatch based on the data types of provided ndarray arguments. The wrapper performs the following tasks:
|
|
43
|
+
|
|
44
|
+
- validates input arguments.
|
|
45
|
+
- casts input ndarrays according to a casting policy.
|
|
46
|
+
- allocates an output ndarray according to an output data type policy.
|
|
47
|
+
|
|
42
48
|
</section>
|
|
43
49
|
|
|
44
50
|
<!-- /.intro -->
|
|
@@ -60,184 +66,210 @@ npm install @stdlib/math-tools-unary
|
|
|
60
66
|
## Usage
|
|
61
67
|
|
|
62
68
|
```javascript
|
|
63
|
-
var
|
|
69
|
+
var factory = require( '@stdlib/math-tools-unary' );
|
|
64
70
|
```
|
|
65
71
|
|
|
66
|
-
####
|
|
72
|
+
#### factory( fcn, idtypes, odtypes, policies )
|
|
67
73
|
|
|
68
|
-
Returns a function which
|
|
74
|
+
Returns a function which performs element-wise computation by applying a unary function to each element in an input ndarray.
|
|
69
75
|
|
|
70
76
|
<!-- eslint-disable array-element-newline -->
|
|
71
77
|
|
|
72
78
|
```javascript
|
|
73
|
-
var
|
|
74
|
-
var
|
|
75
|
-
var
|
|
76
|
-
var
|
|
77
|
-
|
|
78
|
-
var table = {
|
|
79
|
-
'scalar': [
|
|
80
|
-
'number', nabs
|
|
81
|
-
],
|
|
82
|
-
'array': [
|
|
83
|
-
'float64', dabs,
|
|
84
|
-
'float32', sabs,
|
|
85
|
-
'generic', gabs
|
|
86
|
-
],
|
|
87
|
-
'ndarray': [
|
|
88
|
-
'float64', dabs.ndarray,
|
|
89
|
-
'float32', sabs.ndarray,
|
|
90
|
-
'generic', gabs.ndarray
|
|
91
|
-
]
|
|
92
|
-
};
|
|
79
|
+
var base = require( '@stdlib/math-base-special-abs' );
|
|
80
|
+
var dispatch = require( '@stdlib/ndarray-dispatch' );
|
|
81
|
+
var unary = require( '@stdlib/ndarray-base-unary' );
|
|
82
|
+
var ndarray2array = require( '@stdlib/ndarray-to-array' );
|
|
83
|
+
var array = require( '@stdlib/ndarray-array' );
|
|
93
84
|
|
|
94
|
-
var
|
|
85
|
+
var types = [
|
|
86
|
+
'float64', 'float64',
|
|
87
|
+
'float64', 'generic',
|
|
88
|
+
'generic', 'generic'
|
|
89
|
+
];
|
|
90
|
+
var data = [
|
|
91
|
+
base,
|
|
92
|
+
base,
|
|
93
|
+
base
|
|
94
|
+
];
|
|
95
|
+
var dispatcher = dispatch( unary, types, data, 2, 1, 1 );
|
|
96
|
+
|
|
97
|
+
var idt = [ 'float64', 'generic' ];
|
|
98
|
+
var odt = idt;
|
|
99
|
+
|
|
100
|
+
var policies = {
|
|
101
|
+
'output': 'real_and_generic',
|
|
102
|
+
'casting': 'none'
|
|
103
|
+
};
|
|
104
|
+
var ufunc = factory( dispatcher, [ idt ], odt, policies );
|
|
95
105
|
```
|
|
96
106
|
|
|
97
|
-
The function
|
|
98
|
-
|
|
99
|
-
- **table**: resolution table object which maps input argument types to corresponding implementations.
|
|
100
|
-
|
|
101
|
-
A `table` resolution object may contain one or more of the following fields:
|
|
107
|
+
The function has the following arguments:
|
|
102
108
|
|
|
103
|
-
- **
|
|
109
|
+
- **fcn**: function which applies a unary function to each element in an ndarray and assigns results to an output ndarray.
|
|
104
110
|
|
|
105
|
-
- **
|
|
111
|
+
- **idtypes**: list containing lists of supported input data types for each input ndarray argument.
|
|
106
112
|
|
|
107
|
-
|
|
108
|
-
fcn( N, x, strideX, y, strideY )
|
|
109
|
-
```
|
|
113
|
+
- **odtypes**: list of supported output data types.
|
|
110
114
|
|
|
111
|
-
|
|
115
|
+
- **policies**: dispatch policies. Must have the following properties:
|
|
112
116
|
|
|
113
|
-
- **
|
|
114
|
-
- **
|
|
115
|
-
- **strideX**: index increment for `x`.
|
|
116
|
-
- **y**: destination strided array.
|
|
117
|
-
- **strideY**: index increment for `y`.
|
|
117
|
+
- **output**: output data type [policy][@stdlib/ndarray/output-dtype-policies].
|
|
118
|
+
- **casting**: input ndarray casting [policy][@stdlib/ndarray/input-casting-policies].
|
|
118
119
|
|
|
119
|
-
|
|
120
|
+
#### ufunc( x\[, options] )
|
|
120
121
|
|
|
121
|
-
|
|
122
|
+
Performs element-wise computation.
|
|
122
123
|
|
|
123
|
-
|
|
124
|
-
fcn( N, x, strideX, offsetX, y, strideY, offsetY )
|
|
125
|
-
```
|
|
124
|
+
<!-- eslint-disable array-element-newline -->
|
|
126
125
|
|
|
127
|
-
|
|
126
|
+
```javascript
|
|
127
|
+
var base = require( '@stdlib/math-base-special-abs' );
|
|
128
|
+
var dispatch = require( '@stdlib/ndarray-dispatch' );
|
|
129
|
+
var unary = require( '@stdlib/ndarray-base-unary' );
|
|
130
|
+
var ndarray2array = require( '@stdlib/ndarray-to-array' );
|
|
131
|
+
var array = require( '@stdlib/ndarray-array' );
|
|
128
132
|
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
133
|
+
var types = [
|
|
134
|
+
'float64', 'float64',
|
|
135
|
+
'float64', 'generic',
|
|
136
|
+
'generic', 'generic'
|
|
137
|
+
];
|
|
138
|
+
var data = [
|
|
139
|
+
base,
|
|
140
|
+
base,
|
|
141
|
+
base
|
|
142
|
+
];
|
|
143
|
+
var dispatcher = dispatch( unary, types, data, 2, 1, 1 );
|
|
144
|
+
|
|
145
|
+
var idt = [ 'float64', 'generic' ];
|
|
146
|
+
var odt = idt;
|
|
147
|
+
|
|
148
|
+
var policies = {
|
|
149
|
+
'output': 'real_and_generic',
|
|
150
|
+
'casting': 'none'
|
|
151
|
+
};
|
|
152
|
+
var ufunc = factory( dispatcher, [ idt ], odt, policies );
|
|
136
153
|
|
|
137
|
-
|
|
154
|
+
var x = array( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
|
|
155
|
+
// returns <ndarray>
|
|
138
156
|
|
|
139
|
-
|
|
157
|
+
var y = ufunc( x );
|
|
158
|
+
// returns <ndarray>
|
|
140
159
|
|
|
141
|
-
|
|
142
|
-
[
|
|
160
|
+
var arr = ndarray2array( y );
|
|
161
|
+
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
|
|
143
162
|
```
|
|
144
163
|
|
|
145
|
-
|
|
164
|
+
The function has the following parameters:
|
|
146
165
|
|
|
147
|
-
|
|
166
|
+
- **x**: input ndarray.
|
|
167
|
+
- **options**: function options (_optional_).
|
|
148
168
|
|
|
149
|
-
|
|
169
|
+
The function accepts the following options:
|
|
150
170
|
|
|
151
|
-
|
|
171
|
+
- **dtype**: output ndarray data type. Setting this option, overrides the output data type policy.
|
|
172
|
+
- **order**: output ndarray order.
|
|
152
173
|
|
|
153
|
-
|
|
174
|
+
By default, the function returns an ndarray having a data type determined by the output data type policy. To override the default behavior, set the `dtype` option.
|
|
154
175
|
|
|
155
176
|
<!-- eslint-disable array-element-newline -->
|
|
156
177
|
|
|
157
178
|
```javascript
|
|
158
|
-
var
|
|
159
|
-
var
|
|
160
|
-
var
|
|
161
|
-
var
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
'
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
179
|
+
var base = require( '@stdlib/math-base-special-abs' );
|
|
180
|
+
var dispatch = require( '@stdlib/ndarray-dispatch' );
|
|
181
|
+
var unary = require( '@stdlib/ndarray-base-unary' );
|
|
182
|
+
var getDType = require( '@stdlib/ndarray-dtype' );
|
|
183
|
+
var array = require( '@stdlib/ndarray-array' );
|
|
184
|
+
|
|
185
|
+
var types = [
|
|
186
|
+
'float64', 'float64',
|
|
187
|
+
'float64', 'generic',
|
|
188
|
+
'generic', 'generic'
|
|
189
|
+
];
|
|
190
|
+
var data = [
|
|
191
|
+
base,
|
|
192
|
+
base,
|
|
193
|
+
base
|
|
194
|
+
];
|
|
195
|
+
var dispatcher = dispatch( unary, types, data, 2, 1, 1 );
|
|
196
|
+
|
|
197
|
+
var idt = [ 'float64', 'generic' ];
|
|
198
|
+
var odt = idt;
|
|
199
|
+
|
|
200
|
+
var policies = {
|
|
201
|
+
'output': 'real_and_generic',
|
|
202
|
+
'casting': 'none'
|
|
177
203
|
};
|
|
204
|
+
var ufunc = factory( dispatcher, [ idt ], odt, policies );
|
|
178
205
|
|
|
179
|
-
var
|
|
206
|
+
var x = array( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
|
|
207
|
+
// returns <ndarray>
|
|
180
208
|
|
|
181
|
-
var y =
|
|
182
|
-
|
|
183
|
-
|
|
209
|
+
var y = ufunc( x, {
|
|
210
|
+
'dtype': 'generic'
|
|
211
|
+
});
|
|
212
|
+
// returns <ndarray>
|
|
184
213
|
|
|
185
|
-
|
|
214
|
+
var dt = getDType( y );
|
|
215
|
+
// returns 'generic'
|
|
216
|
+
```
|
|
186
217
|
|
|
187
|
-
|
|
218
|
+
#### ufunc.assign( x, out )
|
|
188
219
|
|
|
189
|
-
|
|
220
|
+
Performs element-wise computation and assigns results to a provided output ndarray.
|
|
190
221
|
|
|
191
222
|
<!-- eslint-disable array-element-newline -->
|
|
192
223
|
|
|
193
224
|
```javascript
|
|
194
|
-
var
|
|
195
|
-
var
|
|
196
|
-
var
|
|
225
|
+
var base = require( '@stdlib/math-base-special-abs' );
|
|
226
|
+
var dispatch = require( '@stdlib/ndarray-dispatch' );
|
|
227
|
+
var unary = require( '@stdlib/ndarray-base-unary' );
|
|
228
|
+
var ndarray2array = require( '@stdlib/ndarray-to-array' );
|
|
229
|
+
var zerosLike = require( '@stdlib/ndarray-zeros-like' );
|
|
197
230
|
var array = require( '@stdlib/ndarray-array' );
|
|
198
231
|
|
|
199
|
-
var
|
|
200
|
-
'
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
232
|
+
var types = [
|
|
233
|
+
'float64', 'float64',
|
|
234
|
+
'float64', 'generic',
|
|
235
|
+
'generic', 'generic'
|
|
236
|
+
];
|
|
237
|
+
var data = [
|
|
238
|
+
base,
|
|
239
|
+
base,
|
|
240
|
+
base
|
|
241
|
+
];
|
|
242
|
+
var dispatcher = dispatch( unary, types, data, 2, 1, 1 );
|
|
243
|
+
|
|
244
|
+
var idt = [ 'float64', 'generic' ];
|
|
245
|
+
var odt = idt;
|
|
246
|
+
|
|
247
|
+
var policies = {
|
|
248
|
+
'output': 'real_and_generic',
|
|
249
|
+
'casting': 'none'
|
|
205
250
|
};
|
|
251
|
+
var ufunc = factory( dispatcher, [ idt ], odt, policies );
|
|
206
252
|
|
|
207
|
-
var
|
|
208
|
-
|
|
209
|
-
var x = array( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] ); // 2x2
|
|
210
|
-
var y = abs( x );
|
|
253
|
+
var x = array( [ [ -1.0, -2.0 ], [ -3.0, -4.0 ] ] );
|
|
211
254
|
// returns <ndarray>
|
|
212
255
|
|
|
213
|
-
var
|
|
214
|
-
// returns
|
|
215
|
-
```
|
|
256
|
+
var y = zerosLike( x );
|
|
257
|
+
// returns <ndarray>
|
|
216
258
|
|
|
217
|
-
|
|
259
|
+
var out = ufunc.assign( x, y );
|
|
260
|
+
// returns <ndarray>
|
|
218
261
|
|
|
219
|
-
|
|
262
|
+
var bool = ( out === y );
|
|
263
|
+
// returns true
|
|
220
264
|
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
var gabs = require( '@stdlib/math-strided-special-abs' );
|
|
225
|
-
var Float64Array = require( '@stdlib/array-float64' );
|
|
226
|
-
|
|
227
|
-
var table = {
|
|
228
|
-
'array': [
|
|
229
|
-
'float64', dabs,
|
|
230
|
-
'float32', sabs,
|
|
231
|
-
'generic', gabs
|
|
232
|
-
]
|
|
233
|
-
};
|
|
265
|
+
var arr = ndarray2array( out );
|
|
266
|
+
// returns [ [ 1.0, 2.0 ], [ 3.0, 4.0 ] ]
|
|
267
|
+
```
|
|
234
268
|
|
|
235
|
-
|
|
269
|
+
The method has the following parameters:
|
|
236
270
|
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
// returns <Float64Array>[ 1.0, 2.0 ]
|
|
240
|
-
```
|
|
271
|
+
- **x**: input ndarray.
|
|
272
|
+
- **out**: output ndarray.
|
|
241
273
|
|
|
242
274
|
</section>
|
|
243
275
|
|
|
@@ -247,14 +279,27 @@ var y = abs( x );
|
|
|
247
279
|
|
|
248
280
|
<section class="notes">
|
|
249
281
|
|
|
282
|
+
## Notes
|
|
283
|
+
|
|
284
|
+
- A provided unary function should have the following signature:
|
|
285
|
+
|
|
286
|
+
```text
|
|
287
|
+
f( x, y )
|
|
288
|
+
```
|
|
289
|
+
|
|
290
|
+
where
|
|
291
|
+
|
|
292
|
+
- **x**: input ndarray.
|
|
293
|
+
- **y**: output ndarray.
|
|
294
|
+
|
|
295
|
+
- The output data type policy only applies to the function returned by the main function. For the `assign` method, the output ndarray is allowed to have any supported output data type.
|
|
296
|
+
|
|
250
297
|
</section>
|
|
251
298
|
|
|
252
299
|
<!-- /.notes -->
|
|
253
300
|
|
|
254
301
|
<!-- Package usage examples. -->
|
|
255
302
|
|
|
256
|
-
* * *
|
|
257
|
-
|
|
258
303
|
<section class="examples">
|
|
259
304
|
|
|
260
305
|
## Examples
|
|
@@ -264,63 +309,49 @@ var y = abs( x );
|
|
|
264
309
|
<!-- eslint no-undef: "error" -->
|
|
265
310
|
|
|
266
311
|
```javascript
|
|
267
|
-
var
|
|
268
|
-
var
|
|
269
|
-
var
|
|
270
|
-
var
|
|
271
|
-
var
|
|
272
|
-
var
|
|
273
|
-
var
|
|
274
|
-
var dispatch = require( '@stdlib/math-tools-unary' );
|
|
275
|
-
|
|
276
|
-
var table;
|
|
277
|
-
var sub;
|
|
278
|
-
var abs;
|
|
279
|
-
var sh;
|
|
280
|
-
var x;
|
|
281
|
-
var y;
|
|
282
|
-
var i;
|
|
283
|
-
|
|
284
|
-
// Define a table for resolving unary functions based on argument data types:
|
|
285
|
-
table = {
|
|
286
|
-
'scalar': [
|
|
287
|
-
'number', nabs
|
|
288
|
-
],
|
|
289
|
-
'array': [
|
|
290
|
-
'float64', dabs,
|
|
291
|
-
'float32', sabs,
|
|
292
|
-
'generic', gabs
|
|
293
|
-
],
|
|
294
|
-
'ndarray': [
|
|
295
|
-
'float64', dabs.ndarray,
|
|
296
|
-
'float32', sabs.ndarray,
|
|
297
|
-
'generic', gabs.ndarray
|
|
298
|
-
]
|
|
299
|
-
};
|
|
312
|
+
var base = require( '@stdlib/math-base-special-abs' );
|
|
313
|
+
var basef = require( '@stdlib/math-base-special-absf' );
|
|
314
|
+
var uniform = require( '@stdlib/random-uniform' );
|
|
315
|
+
var dispatch = require( '@stdlib/ndarray-dispatch' );
|
|
316
|
+
var ndarray2array = require( '@stdlib/ndarray-to-array' );
|
|
317
|
+
var unary = require( '@stdlib/ndarray-base-unary' );
|
|
318
|
+
var ufunc = require( '@stdlib/math-tools-unary' );
|
|
300
319
|
|
|
301
320
|
// Create a function which dispatches based on argument data types:
|
|
302
|
-
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
|
|
306
|
-
|
|
307
|
-
|
|
308
|
-
|
|
309
|
-
|
|
310
|
-
|
|
311
|
-
|
|
312
|
-
|
|
313
|
-
|
|
314
|
-
|
|
315
|
-
|
|
316
|
-
|
|
317
|
-
|
|
318
|
-
|
|
319
|
-
|
|
320
|
-
|
|
321
|
-
|
|
322
|
-
|
|
323
|
-
|
|
321
|
+
var types = [
|
|
322
|
+
'float64', 'float64',
|
|
323
|
+
'float32', 'float32',
|
|
324
|
+
'generic', 'generic'
|
|
325
|
+
];
|
|
326
|
+
var data = [
|
|
327
|
+
base,
|
|
328
|
+
basef,
|
|
329
|
+
base
|
|
330
|
+
];
|
|
331
|
+
var dispatcher = dispatch( unary, types, data, 2, 1, 1 );
|
|
332
|
+
|
|
333
|
+
// Define the supported input and output data types:
|
|
334
|
+
var idt = [ 'float64', 'float32', 'generic' ];
|
|
335
|
+
var odt = [ 'float64', 'float32', 'generic' ];
|
|
336
|
+
|
|
337
|
+
// Define dispatch policies:
|
|
338
|
+
var policies = {
|
|
339
|
+
'output': 'same',
|
|
340
|
+
'casting': 'none'
|
|
341
|
+
};
|
|
342
|
+
|
|
343
|
+
// Create a function that performs element-wise computation:
|
|
344
|
+
var abs = ufunc( dispatcher, [ idt ], odt, policies );
|
|
345
|
+
|
|
346
|
+
// Generate an array of random numbers:
|
|
347
|
+
var x = uniform( [ 5, 5 ], -10.0, 10.0, {
|
|
348
|
+
'dtype': 'float64'
|
|
349
|
+
});
|
|
350
|
+
console.log( ndarray2array( x ) );
|
|
351
|
+
|
|
352
|
+
// Perform element-wise computation:
|
|
353
|
+
var y = abs( x );
|
|
354
|
+
console.log( ndarray2array( y ) );
|
|
324
355
|
```
|
|
325
356
|
|
|
326
357
|
</section>
|
|
@@ -369,7 +400,7 @@ See [LICENSE][stdlib-license].
|
|
|
369
400
|
|
|
370
401
|
## Copyright
|
|
371
402
|
|
|
372
|
-
Copyright © 2016-
|
|
403
|
+
Copyright © 2016-2026. The Stdlib [Authors][stdlib-authors].
|
|
373
404
|
|
|
374
405
|
</section>
|
|
375
406
|
|
|
@@ -382,8 +413,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
382
413
|
[npm-image]: http://img.shields.io/npm/v/@stdlib/math-tools-unary.svg
|
|
383
414
|
[npm-url]: https://npmjs.org/package/@stdlib/math-tools-unary
|
|
384
415
|
|
|
385
|
-
[test-image]: https://github.com/stdlib-js/math-tools-unary/actions/workflows/test.yml/badge.svg?branch=v0.
|
|
386
|
-
[test-url]: https://github.com/stdlib-js/math-tools-unary/actions/workflows/test.yml?query=branch:v0.
|
|
416
|
+
[test-image]: https://github.com/stdlib-js/math-tools-unary/actions/workflows/test.yml/badge.svg?branch=v0.3.0
|
|
417
|
+
[test-url]: https://github.com/stdlib-js/math-tools-unary/actions/workflows/test.yml?query=branch:v0.3.0
|
|
387
418
|
|
|
388
419
|
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-tools-unary/main.svg
|
|
389
420
|
[coverage-url]: https://codecov.io/github/stdlib-js/math-tools-unary?branch=main
|
|
@@ -395,8 +426,8 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
395
426
|
|
|
396
427
|
-->
|
|
397
428
|
|
|
398
|
-
[chat-image]: https://img.shields.io/
|
|
399
|
-
[chat-url]: https://
|
|
429
|
+
[chat-image]: https://img.shields.io/badge/zulip-join_chat-brightgreen.svg
|
|
430
|
+
[chat-url]: https://stdlib.zulipchat.com
|
|
400
431
|
|
|
401
432
|
[stdlib]: https://github.com/stdlib-js/stdlib
|
|
402
433
|
|
|
@@ -415,9 +446,9 @@ Copyright © 2016-2024. The Stdlib [Authors][stdlib-authors].
|
|
|
415
446
|
|
|
416
447
|
[stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-tools-unary/main/LICENSE
|
|
417
448
|
|
|
418
|
-
[@stdlib/ndarray/
|
|
449
|
+
[@stdlib/ndarray/output-dtype-policies]: https://www.npmjs.com/package/@stdlib/ndarray-output-dtype-policies
|
|
419
450
|
|
|
420
|
-
[@stdlib/ndarray/
|
|
451
|
+
[@stdlib/ndarray/input-casting-policies]: https://www.npmjs.com/package/@stdlib/ndarray-input-casting-policies
|
|
421
452
|
|
|
422
453
|
</section>
|
|
423
454
|
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,3 @@
|
|
|
1
1
|
/// <reference path="../docs/types/index.d.ts" />
|
|
2
|
-
import
|
|
3
|
-
export =
|
|
2
|
+
import factory from '../docs/types/index';
|
|
3
|
+
export = factory;
|
package/dist/index.js
CHANGED
|
@@ -1,19 +1,7 @@
|
|
|
1
|
-
"use strict";var
|
|
2
|
-
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
8
|
-
* you may not use this file except in compliance with the License.
|
|
9
|
-
* You may obtain a copy of the License at
|
|
10
|
-
*
|
|
11
|
-
* http://www.apache.org/licenses/LICENSE-2.0
|
|
12
|
-
*
|
|
13
|
-
* Unless required by applicable law or agreed to in writing, software
|
|
14
|
-
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
15
|
-
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
16
|
-
* See the License for the specific language governing permissions and
|
|
17
|
-
* limitations under the License.
|
|
18
|
-
*/
|
|
1
|
+
"use strict";var O=function(a,r){return function(){return r||a((r={exports:{}}).exports,r),r.exports}};var D=O(function(tr,F){
|
|
2
|
+
var H=require('@stdlib/assert-is-plain-object/dist'),V=require('@stdlib/assert-has-own-property/dist'),J=require('@stdlib/ndarray-base-assert-is-order/dist'),K=require('@stdlib/array-base-assert-contains/dist'),M=require('@stdlib/ndarray-orders/dist'),j=require('@stdlib/array-base-join/dist'),h=require('@stdlib/error-tools-fmtprodmsg/dist');function N(a,r,t){return H(t)?V(t,"dtype")&&(a.dtype=t.dtype,!K(r,String(a.dtype)))?new TypeError(h('0gz4S',"dtype",j(r,'", "'),a.dtype)):V(t,"order")&&(a.order=t.order,!J(a.order))?new TypeError(h('0gz4S',"order",j(M(),'", "'),a.order)):null:new TypeError(h('0gz2V',t));}F.exports=N
|
|
3
|
+
});var z=O(function(nr,R){
|
|
4
|
+
var Q=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),q=require('@stdlib/assert-is-ndarray-like/dist'),U=require('@stdlib/assert-is-function/dist'),W=require('@stdlib/assert-is-object/dist'),c=require('@stdlib/assert-is-collection/dist'),X=require('@stdlib/ndarray-base-assert-is-output-data-type-policy/dist'),Y=require('@stdlib/ndarray-base-assert-is-input-casting-policy/dist'),S=require('@stdlib/ndarray-base-assert-is-data-type/dist'),P=require('@stdlib/array-base-assert-contains/dist'),Z=require('@stdlib/ndarray-base-unary-output-dtype/dist'),C=require('@stdlib/ndarray-base-unary-input-casting-dtype/dist'),I=require('@stdlib/ndarray-base-assign/dist'),k=require('@stdlib/ndarray-base-empty/dist'),_=require('@stdlib/ndarray-maybe-broadcast-array/dist'),b=require('@stdlib/ndarray-shape/dist'),A=require('@stdlib/ndarray-order/dist'),T=require('@stdlib/ndarray-dtype/dist'),$=require('@stdlib/ndarray-empty/dist'),B=require('@stdlib/array-base-every-by/dist'),L=require('@stdlib/array-base-join/dist'),n=require('@stdlib/error-tools-fmtprodmsg/dist'),x=D();function rr(a,r,t,o){var m,d,l;if(!U(a))throw new TypeError(n('0gz3c',a));if(!c(r))throw new TypeError(n('0gz2y',r));for(l=0;l<r.length;l++)if(d=r[l],!c(d)||d.length<1||!B(d,S))throw new TypeError(n('0gzHw',r));if(!c(t)||t.length<1||!B(t,S))throw new TypeError(n('0gzHX',t));if(!W(o))throw new TypeError(n('0gz43',o));if(!X(o.output))throw new TypeError(n('0gzI6',o.output));if(!Y(o.casting))throw new TypeError(n('0gzI7',o.casting));return m={output:o.output,casting:o.casting},Q(E,"assign",G),E;function E(e){var u,i,v,s,g,y,p,f,w;if(!q(e))throw new TypeError(n('0gz4f',e));if(g=T(e),!P(r[0],g))throw new TypeError(n('0gzHZ',L(r[0],'", "'),g));if(u={},arguments.length>1&&(i=x(u,t,arguments[1]),i))throw i;return v=b(e),s=A(e),y=u.dtype||Z(g,m.output),w=$(v,{dtype:y,order:u.order||s}),f=C(g,y,m.casting),g!==f&&(p=k(f,v,s),I([e,p]),e=p),a(e,w),w}function G(e,u){var i,v,s;if(!q(e))throw new TypeError(n('0gz4f',e));if(!q(u))throw new TypeError(n('0gzF1',u));if(i=T(e),!P(r[0],i))throw new TypeError(n('0gzHZ',L(r[0],'", "'),i));return s=C(i,T(u),m.casting),i!==s&&(v=k(s,b(e),A(e)),I([e,v]),e=v),a(_(e,b(u)),u),u}}R.exports=rr
|
|
5
|
+
});var er=z();module.exports=er;
|
|
6
|
+
/** @license Apache-2.0 */
|
|
19
7
|
//# sourceMappingURL=index.js.map
|