@stdlib/math-strided-special-abs2-by 0.0.8 → 0.2.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-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2024 The Stdlib Authors.
package/README.md CHANGED
@@ -20,6 +20,17 @@ limitations under the License.
20
20
 
21
21
  <!-- lint disable maximum-heading-length -->
22
22
 
23
+
24
+ <details>
25
+ <summary>
26
+ About stdlib...
27
+ </summary>
28
+ <p>We believe in a future in which the web is a preferred environment for numerical computation. To help realize this future, we've built stdlib. stdlib is a standard library, with an emphasis on numerical and scientific computation, written in JavaScript (and C) for execution in browsers and in Node.js.</p>
29
+ <p>The library is fully decomposable, being architected in such a way that you can swap out and mix and match APIs and functionality to cater to your exact preferences and use cases.</p>
30
+ <p>When you use stdlib, you can be absolutely certain that you are using the most thorough, rigorous, well-written, studied, documented, tested, measured, and high-quality code out there.</p>
31
+ <p>To join us in bringing numerical computing to the web, get started by checking us out on <a href="https://github.com/stdlib-js/stdlib">GitHub</a>, and please consider <a href="https://opencollective.com/stdlib">financially supporting stdlib</a>. We greatly appreciate your continued support!</p>
32
+ </details>
33
+
23
34
  # abs2By
24
35
 
25
36
  [![NPM version][npm-image]][npm-url] [![Build Status][test-image]][test-url] [![Coverage Status][coverage-image]][coverage-url] <!-- [![dependencies][dependencies-image]][dependencies-url] -->
@@ -104,7 +115,7 @@ abs2By( x.length, x, 1, y, 1, accessor, context );
104
115
  // y => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]
105
116
 
106
117
  var cnt = context.count;
107
- // returns 8
118
+ // returns 5
108
119
  ```
109
120
 
110
121
  The `N` and `stride` parameters determine which elements in `x` and `y` are accessed at runtime. For example, to index every other value in `x` and to index the first `N` elements of `y` in reverse order,
@@ -210,8 +221,9 @@ abs2By.ndarray( 3, x, 2, 1, y, -1, y.length-1, accessor );
210
221
  <!-- eslint no-undef: "error" -->
211
222
 
212
223
  ```javascript
213
- var uniform = require( '@stdlib/random-base-uniform' );
224
+ var uniform = require( '@stdlib/random-base-uniform' ).factory
214
225
  var filledarray = require( '@stdlib/array-filled' );
226
+ var filledarrayBy = require( '@stdlib/array-filled-by' );
215
227
  var abs2By = require( '@stdlib/math-strided-special-abs2-by' );
216
228
 
217
229
  function accessor( v, i ) {
@@ -222,14 +234,10 @@ function accessor( v, i ) {
222
234
  return v;
223
235
  }
224
236
 
225
- var x = filledarray( 0.0, 10, 'generic' );
226
- var y = filledarray( null, 10, 'generic' );
227
-
228
- var i;
229
- for ( i = 0; i < x.length; i++ ) {
230
- x[ i ] = uniform( -10.0, 10.0 );
231
- }
237
+ var x = filledarrayBy( 10, 'generic', uniform( -10.0, 10.0 ) );
232
238
  console.log( x );
239
+
240
+ var y = filledarray( null, 10, 'generic' );
233
241
  console.log( y );
234
242
 
235
243
  abs2By.ndarray( x.length, x, 1, 0, y, -1, y.length-1, accessor );
@@ -248,8 +256,8 @@ console.log( y );
248
256
 
249
257
  ## See Also
250
258
 
251
- - <span class="package-name">[`@stdlib/math/strided/special/abs-by`][@stdlib/math/strided/special/abs-by]</span><span class="delimiter">: </span><span class="description">compute the absolute value of each element retrieved from a strided input array via a callback function and assign each result to an element in a strided output array.</span>
252
- - <span class="package-name">[`@stdlib/math/strided/special/abs2`][@stdlib/math/strided/special/abs2]</span><span class="delimiter">: </span><span class="description">compute the squared absolute value for each element in a strided array.</span>
259
+ - <span class="package-name">[`@stdlib/math-strided/special/abs-by`][@stdlib/math/strided/special/abs-by]</span><span class="delimiter">: </span><span class="description">compute the absolute value of each element retrieved from a strided input array via a callback function and assign each result to an element in a strided output array.</span>
260
+ - <span class="package-name">[`@stdlib/math-strided/special/abs2`][@stdlib/math/strided/special/abs2]</span><span class="delimiter">: </span><span class="description">compute the squared absolute value for each element in a strided array.</span>
253
261
 
254
262
  </section>
255
263
 
@@ -281,7 +289,7 @@ See [LICENSE][stdlib-license].
281
289
 
282
290
  ## Copyright
283
291
 
284
- Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
292
+ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
285
293
 
286
294
  </section>
287
295
 
@@ -294,8 +302,8 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
294
302
  [npm-image]: http://img.shields.io/npm/v/@stdlib/math-strided-special-abs2-by.svg
295
303
  [npm-url]: https://npmjs.org/package/@stdlib/math-strided-special-abs2-by
296
304
 
297
- [test-image]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml/badge.svg?branch=v0.0.8
298
- [test-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml?query=branch:v0.0.8
305
+ [test-image]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml/badge.svg?branch=v0.2.0
306
+ [test-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml?query=branch:v0.2.0
299
307
 
300
308
  [coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/math-strided-special-abs2-by/main.svg
301
309
  [coverage-url]: https://codecov.io/github/stdlib-js/math-strided-special-abs2-by?branch=main
@@ -308,7 +316,7 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
308
316
  -->
309
317
 
310
318
  [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
311
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
319
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
312
320
 
313
321
  [stdlib]: https://github.com/stdlib-js/stdlib
314
322
 
@@ -318,8 +326,11 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
318
326
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
319
327
 
320
328
  [deno-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/deno
329
+ [deno-readme]: https://github.com/stdlib-js/math-strided-special-abs2-by/blob/deno/README.md
321
330
  [umd-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/umd
331
+ [umd-readme]: https://github.com/stdlib-js/math-strided-special-abs2-by/blob/umd/README.md
322
332
  [esm-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/esm
333
+ [esm-readme]: https://github.com/stdlib-js/math-strided-special-abs2-by/blob/esm/README.md
323
334
  [branches-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/blob/main/branches.md
324
335
 
325
336
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-strided-special-abs2-by/main/LICENSE
package/SECURITY.md ADDED
@@ -0,0 +1,5 @@
1
+ # Security
2
+
3
+ > Policy for reporting security vulnerabilities.
4
+
5
+ See the security policy [in the main project repository](https://github.com/stdlib-js/stdlib/security).
@@ -0,0 +1,3 @@
1
+ /// <reference path="../docs/types/index.d.ts" />
2
+ import abs2By from '../docs/types/index';
3
+ export = abs2By;
package/dist/index.js ADDED
@@ -0,0 +1,7 @@
1
+ "use strict";var n=function(e,r){return function(){return r||e((r={exports:{}}).exports,r),r.exports}};var q=n(function(h,y){
2
+ var d=require('@stdlib/strided-base-map-by/dist'),B=require('@stdlib/math-base-special-abs2/dist');function m(e,r,a,s,t,u,i){return d(e,r,a,s,t,B,u,i)}y.exports=m
3
+ });var c=n(function(j,v){
4
+ var x=require('@stdlib/strided-base-map-by/dist').ndarray,f=require('@stdlib/math-base-special-abs2/dist');function l(e,r,a,s,t,u,i,p,b){return x(e,r,a,s,t,u,i,f,p,b)}v.exports=l
5
+ });var O=require('@stdlib/utils-define-nonenumerable-read-only-property/dist'),o=q(),R=c();O(o,"ndarray",R);module.exports=o;
6
+ /** @license Apache-2.0 */
7
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1,7 @@
1
+ {
2
+ "version": 3,
3
+ "sources": ["../lib/main.js", "../lib/ndarray.js", "../lib/index.js"],
4
+ "sourcesContent": ["/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n// MODULES //\n\nvar mapBy = require( '@stdlib/strided-base-map-by' );\nvar abs2 = require( '@stdlib/math-base-special-abs2' );\n\n\n// MAIN //\n\n/**\n* Computes the squared absolute value of each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} x - input array/collection\n* @param {integer} strideX - `x` stride length\n* @param {Collection} y - destination array/collection\n* @param {integer} strideY - `y` stride length\n* @param {Callback} clbk - callback\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} `y`\n*\n* @example\n* function accessor( v ) {\n* return v;\n* }\n*\n* var x = [ -1.0, -2.0, -3.0, -4.0, -5.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* abs2By( x.length, x, 1, y, 1, accessor );\n*\n* console.log( y );\n* // => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]\n*/\nfunction abs2By( N, x, strideX, y, strideY, clbk, thisArg ) {\n\treturn mapBy( N, x, strideX, y, strideY, abs2, clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = abs2By;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n/* eslint-disable max-len */\n\n'use strict';\n\n// MODULES //\n\nvar mapBy = require( '@stdlib/strided-base-map-by' ).ndarray;\nvar abs2 = require( '@stdlib/math-base-special-abs2' );\n\n\n// MAIN //\n\n/**\n* Computes the squared absolute value of each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y`.\n*\n* @param {NonNegativeInteger} N - number of indexed elements\n* @param {Collection} x - input array/collection\n* @param {integer} strideX - `x` stride length\n* @param {NonNegativeInteger} offsetX - starting `x` index\n* @param {Collection} y - destination array/collection\n* @param {integer} strideY - `y` stride length\n* @param {NonNegativeInteger} offsetY - starting `y` index\n* @param {Callback} clbk - callback\n* @param {*} [thisArg] - callback execution context\n* @returns {Collection} `y`\n*\n* @example\n* function accessor( v ) {\n* return v;\n* }\n*\n* var x = [ -1.0, -2.0, -3.0, -4.0, -5.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* abs2By( x.length, x, 1, 0, y, 1, 0, accessor );\n*\n* console.log( y );\n* // => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]\n*/\nfunction abs2By( N, x, strideX, offsetX, y, strideY, offsetY, clbk, thisArg ) {\n\treturn mapBy( N, x, strideX, offsetX, y, strideY, offsetY, abs2, clbk, thisArg );\n}\n\n\n// EXPORTS //\n\nmodule.exports = abs2By;\n", "/**\n* @license Apache-2.0\n*\n* Copyright (c) 2021 The Stdlib Authors.\n*\n* Licensed under the Apache License, Version 2.0 (the \"License\");\n* you may not use this file except in compliance with the License.\n* You may obtain a copy of the License at\n*\n* http://www.apache.org/licenses/LICENSE-2.0\n*\n* Unless required by applicable law or agreed to in writing, software\n* distributed under the License is distributed on an \"AS IS\" BASIS,\n* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.\n* See the License for the specific language governing permissions and\n* limitations under the License.\n*/\n\n'use strict';\n\n/**\n* Compute the squared absolute value of each element retrieved from an input strided array `x` via a callback function and assign each result to an element in an output strided array `y`.\n*\n* @module @stdlib/math-strided-special-abs2-by\n*\n* @example\n* var abs2By = require( '@stdlib/math-strided-special-abs2-by' );\n*\n* function accessor( v ) {\n* return v;\n* }\n*\n* var x = [ -1.0, -2.0, -3.0, -4.0, -5.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* abs2By( x.length, x, 1, y, 1, accessor );\n*\n* console.log( y );\n* // => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]\n*\n* @example\n* var abs2By = require( '@stdlib/math-strided-special-abs2-by' );\n*\n* function accessor( v ) {\n* return v;\n* }\n*\n* var x = [ -1.0, -2.0, -3.0, -4.0, -5.0 ];\n* var y = [ 0.0, 0.0, 0.0, 0.0, 0.0 ];\n*\n* abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );\n*\n* console.log( y );\n* // => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]\n*/\n\n// MODULES //\n\nvar setReadOnly = require( '@stdlib/utils-define-nonenumerable-read-only-property' );\nvar main = require( './main.js' );\nvar ndarray = require( './ndarray.js' );\n\n\n// MAIN //\n\nsetReadOnly( main, 'ndarray', ndarray );\n\n\n// EXPORTS //\n\nmodule.exports = main;\n"],
5
+ "mappings": "uGAAA,IAAAA,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAsBA,IAAIC,EAAQ,QAAS,6BAA8B,EAC/CC,EAAO,QAAS,gCAAiC,EA8BrD,SAASC,EAAQC,EAAGC,EAAGC,EAASC,EAAGC,EAASC,EAAMC,EAAU,CAC3D,OAAOT,EAAOG,EAAGC,EAAGC,EAASC,EAAGC,EAASN,EAAMO,EAAMC,CAAQ,CAC9D,CAKAV,EAAO,QAAUG,IC5DjB,IAAAQ,EAAAC,EAAA,SAAAC,EAAAC,EAAA,cAwBA,IAAIC,EAAQ,QAAS,6BAA8B,EAAE,QACjDC,EAAO,QAAS,gCAAiC,EAgCrD,SAASC,EAAQC,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAASC,EAAMC,EAAU,CAC7E,OAAOX,EAAOG,EAAGC,EAAGC,EAASC,EAASC,EAAGC,EAASC,EAASR,EAAMS,EAAMC,CAAQ,CAChF,CAKAZ,EAAO,QAAUG,ICNjB,IAAIU,EAAc,QAAS,uDAAwD,EAC/EC,EAAO,IACPC,EAAU,IAKdF,EAAaC,EAAM,UAAWC,CAAQ,EAKtC,OAAO,QAAUD",
6
+ "names": ["require_main", "__commonJSMin", "exports", "module", "mapBy", "abs2", "abs2By", "N", "x", "strideX", "y", "strideY", "clbk", "thisArg", "require_ndarray", "__commonJSMin", "exports", "module", "mapBy", "abs2", "abs2By", "N", "x", "strideX", "offsetX", "y", "strideY", "offsetY", "clbk", "thisArg", "setReadOnly", "main", "ndarray"]
7
+ }
@@ -16,18 +16,18 @@
16
16
  * limitations under the License.
17
17
  */
18
18
 
19
- // TypeScript Version: 2.0
19
+ // TypeScript Version: 4.1
20
20
 
21
21
  /// <reference types="@stdlib/types"/>
22
22
 
23
- import { Collection } from '@stdlib/types/object';
23
+ import { Collection } from '@stdlib/types/array';
24
24
 
25
25
  /**
26
26
  * Returns an accessed value.
27
27
  *
28
28
  * @returns accessed value
29
29
  */
30
- type Nullary = () => number | void;
30
+ type Nullary<V> = ( this: V ) => number | void;
31
31
 
32
32
  /**
33
33
  * Returns an accessed value.
@@ -35,7 +35,7 @@ type Nullary = () => number | void;
35
35
  * @param value - array element
36
36
  * @returns accessed value
37
37
  */
38
- type Unary = ( value: any ) => number | void;
38
+ type Unary<T, V> = ( this: V, value: T ) => number | void;
39
39
 
40
40
  /**
41
41
  * Returns an accessed value.
@@ -44,7 +44,7 @@ type Unary = ( value: any ) => number | void;
44
44
  * @param idx - iteration index
45
45
  * @returns accessed value
46
46
  */
47
- type Binary = ( value: any, idx: number ) => number | void;
47
+ type Binary<T, V> = ( this: V, value: T, idx: number ) => number | void;
48
48
 
49
49
  /**
50
50
  * Returns an accessed value.
@@ -54,7 +54,7 @@ type Binary = ( value: any, idx: number ) => number | void;
54
54
  * @param xi - strided index (offsetX + idx*strideX)
55
55
  * @returns accessed value
56
56
  */
57
- type Ternary = ( value: any, idx: number, xi: number ) => number | void;
57
+ type Ternary<T, V> = ( this: V, value: T, idx: number, xi: number ) => number | void;
58
58
 
59
59
  /**
60
60
  * Returns an accessed value.
@@ -65,8 +65,7 @@ type Ternary = ( value: any, idx: number, xi: number ) => number | void;
65
65
  * @param yi - strided index (offsetY + idx*strideY)
66
66
  * @returns accessed value
67
67
  */
68
- type Quaternary = ( value: any, idx: number, xi: number, yi: number ) => number | void; // tslint-disable-line max-line-length
69
-
68
+ type Quaternary<T, V> = ( this: V, value: T, idx: number, xi: number, yi: number ) => number | void;
70
69
  /**
71
70
  * Returns an accessed value.
72
71
  *
@@ -77,8 +76,7 @@ type Quaternary = ( value: any, idx: number, xi: number, yi: number ) => number
77
76
  * @param x - input array
78
77
  * @returns accessed value
79
78
  */
80
- type Quinary = ( value: any, idx: number, xi: number, yi: number, x: Collection ) => number | void; // tslint-disable-line max-line-length
81
-
79
+ type Quinary<T, V> = ( this: V, value: T, idx: number, xi: number, yi: number, x: Collection<T> ) => number | void;
82
80
  /**
83
81
  * Returns an accessed value.
84
82
  *
@@ -90,8 +88,7 @@ type Quinary = ( value: any, idx: number, xi: number, yi: number, x: Collection
90
88
  * @param y - output array
91
89
  * @returns accessed value
92
90
  */
93
- type Senary = ( value: any, idx: number, xi: number, yi: number, x: Collection, y: Collection ) => number | void; // tslint-disable-line max-line-length
94
-
91
+ type Senary<T, U, V> = ( this: V, value: T, idx: number, xi: number, yi: number, x: Collection<T>, y: Collection<U> ) => number | void;
95
92
  /**
96
93
  * Returns an accessed value.
97
94
  *
@@ -103,7 +100,7 @@ type Senary = ( value: any, idx: number, xi: number, yi: number, x: Collection,
103
100
  * @param y - output array
104
101
  * @returns accessed value
105
102
  */
106
- type Callback = Nullary | Unary | Binary | Ternary | Quaternary | Quinary | Senary; // tslint-disable-line max-line-length
103
+ type Callback<T, U, V> = Nullary<V> | Unary<T, V> | Binary<T, V> | Ternary<T, V> | Quaternary<T, V> | Quinary<T, V> | Senary<T, U, V>;
107
104
 
108
105
  /**
109
106
  * Interface describing `abs2By`.
@@ -132,7 +129,7 @@ interface Routine {
132
129
  * abs2By( x.length, x, 1, y, 1, accessor );
133
130
  * // y => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]
134
131
  */
135
- ( N: number, x: Collection, strideX: number, y: Collection, strideY: number, clbk: Callback, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
132
+ <T = unknown, U = unknown, V = unknown>( N: number, x: Collection<T>, strideX: number, y: Collection<U>, strideY: number, clbk: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): Collection<U | number>;
136
133
 
137
134
  /**
138
135
  * Computes the squared absolute value of each element retrieved from an input strided array `x` via a callback function and assigns each result to an element in an output strided array `y` using alternative indexing semantics.
@@ -159,7 +156,7 @@ interface Routine {
159
156
  * abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, accessor );
160
157
  * // y => [ 1.0, 4.0, 9.0, 16.0, 25.0 ]
161
158
  */
162
- ndarray( N: number, x: Collection, strideX: number, offsetX: number, y: Collection, strideY: number, offsetY: number, clbk: Callback, thisArg?: any ): Collection; // tslint:disable-line:max-line-length
159
+ ndarray<T = unknown, U = unknown, V = unknown>( N: number, x: Collection<T>, strideX: number, offsetX: number, y: Collection<U>, strideY: number, offsetY: number, clbk: Callback<T, U, V>, thisArg?: ThisParameterType<Callback<T, U, V>> ): Collection<U | number>;
163
160
  }
164
161
 
165
162
  /**
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@stdlib/math-strided-special-abs2-by",
3
- "version": "0.0.8",
3
+ "version": "0.2.0",
4
4
  "description": "Compute the squared absolute value of each element retrieved from an input strided array via a callback function.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
@@ -37,21 +37,23 @@
37
37
  "url": "https://github.com/stdlib-js/stdlib/issues"
38
38
  },
39
39
  "dependencies": {
40
- "@stdlib/math-base-special-abs2": "^0.0.x",
41
- "@stdlib/strided-base-map-by": "^0.0.x",
42
- "@stdlib/types": "^0.0.x",
43
- "@stdlib/utils-define-nonenumerable-read-only-property": "^0.0.x"
40
+ "@stdlib/math-base-special-abs2": "^0.2.0",
41
+ "@stdlib/strided-base-map-by": "^0.2.0",
42
+ "@stdlib/types": "^0.3.1",
43
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.2.0"
44
44
  },
45
45
  "devDependencies": {
46
- "@stdlib/array-filled": "^0.0.x",
47
- "@stdlib/array-float64": "^0.0.x",
48
- "@stdlib/bench": "^0.0.x",
49
- "@stdlib/math-base-assert-is-nan": "^0.0.x",
50
- "@stdlib/math-base-special-pow": "^0.0.x",
51
- "@stdlib/random-base-uniform": "^0.0.x",
46
+ "@stdlib/array-filled": "^0.1.0",
47
+ "@stdlib/array-filled-by": "^0.1.0",
48
+ "@stdlib/array-float64": "^0.2.0",
49
+ "@stdlib/math-base-assert-is-nan": "^0.2.0",
50
+ "@stdlib/math-base-special-pow": "^0.2.0",
51
+ "@stdlib/random-base-uniform": "^0.1.0",
52
52
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
53
53
  "istanbul": "^0.4.1",
54
- "tap-spec": "5.x.x"
54
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git",
55
+ "@stdlib/bench-harness": "^0.2.0",
56
+ "@stdlib/bench": "^0.3.1"
55
57
  },
56
58
  "engines": {
57
59
  "node": ">=0.10.0",
@@ -92,7 +94,7 @@
92
94
  ],
93
95
  "__stdlib__": {},
94
96
  "funding": {
95
- "type": "patreon",
96
- "url": "https://www.patreon.com/athan"
97
+ "type": "opencollective",
98
+ "url": "https://opencollective.com/stdlib"
97
99
  }
98
100
  }
package/docs/repl.txt DELETED
@@ -1,142 +0,0 @@
1
-
2
- {{alias}}( N, x, sx, y, sy, clbk[, thisArg] )
3
- Computes the squared absolute value of each element retrieved from an input
4
- strided array `x` via a callback function and assigns each result to an
5
- element in an output strided array `y`.
6
-
7
- The `N` and stride parameters determine which elements in `x` and `y` are
8
- accessed at runtime.
9
-
10
- Indexing is relative to the first index. To introduce an offset, use typed
11
- array views.
12
-
13
- The callback function is provided six arguments:
14
-
15
- - value: array element
16
- - idx: iteration index
17
- - xi: strided index (offsetX + idx*sx)
18
- - yi: strided index (offsetY + idx*sy)
19
- - x: the input array
20
- - y: the destination array
21
-
22
- If the callback function does not return any value (or equivalently,
23
- explicitly returns `undefined`), the value is ignored.
24
-
25
- Parameters
26
- ----------
27
- N: integer
28
- Number of indexed elements.
29
-
30
- x: Array|TypedArray|Object
31
- Input array/collection. If provided an object, the object must be array-
32
- like (excluding strings and functions).
33
-
34
- sx: integer
35
- Index increment for `x`.
36
-
37
- y: Array|TypedArray|Object
38
- Destination array/collection. If provided an object, the object must be
39
- array-like (excluding strings and functions).
40
-
41
- sy: integer
42
- Index increment for `y`.
43
-
44
- clbk: Function
45
- Callback function.
46
-
47
- thisArg: any (optional)
48
- Callback execution context.
49
-
50
- Returns
51
- -------
52
- y: Array|TypedArray|Object
53
- Destination array/collection.
54
-
55
- Examples
56
- --------
57
- // Standard usage:
58
- > var x = [ -1.0, -2.0, -3.0, -4.0 ];
59
- > var y = [ 0.0, 0.0, 0.0, 0.0 ];
60
- > function clbk( v ) { return v; };
61
- > {{alias}}( x.length, x, 1, y, 1, clbk )
62
- [ 1.0, 4.0, 9.0, 16.0 ]
63
-
64
- // Using `N` and stride parameters:
65
- > y = [ 0.0, 0.0, 0.0, 0.0 ];
66
- > {{alias}}( 2, x, 2, y, -1, clbk )
67
- [ 9.0, 1.0, 0.0, 0.0 ]
68
-
69
- // Using view offsets:
70
- > var x0 = new {{alias:@stdlib/array/float64}}( [ -1.0, -2.0, -3.0, -4.0 ] );
71
- > var y0 = new {{alias:@stdlib/array/float64}}( [ 0.0, 0.0, 0.0, 0.0 ] );
72
- > var x1 = new {{alias:@stdlib/array/float64}}( x0.buffer, x0.BYTES_PER_ELEMENT*1 );
73
- > var y1 = new {{alias:@stdlib/array/float64}}( y0.buffer, y0.BYTES_PER_ELEMENT*2 );
74
- > {{alias}}( 2, x1, -2, y1, 1, clbk )
75
- <Float64Array>[ 16.0, 4.0 ]
76
- > y0
77
- <Float64Array>[ 0.0, 0.0, 16.0, 4.0 ]
78
-
79
-
80
- {{alias}}.ndarray( N, x, sx, ox, y, sy, oy, clbk[, thisArg] )
81
- Computes the squared absolute value of each element retrieved from an input
82
- strided array `x` via a callback function and assigns each result to an
83
- element in an output strided array `y` using alternative indexing semantics.
84
-
85
- While typed array views mandate a view offset based on the underlying
86
- buffer, the offset parameters support indexing semantics based on starting
87
- indices.
88
-
89
- Parameters
90
- ----------
91
- N: integer
92
- Number of indexed elements.
93
-
94
- x: Array|TypedArray|Object
95
- Input array/collection. If provided an object, the object must be array-
96
- like (excluding strings and functions).
97
-
98
- sx: integer
99
- Index increment for `x`.
100
-
101
- ox: integer
102
- Starting index for `x`.
103
-
104
- y: Array|TypedArray|Object
105
- Destination array/collection. If provided an object, the object must be
106
- array-like (excluding strings and functions).
107
-
108
- sy: integer
109
- Index increment for `y`.
110
-
111
- oy: integer
112
- Starting index for `y`.
113
-
114
- clbk: Function
115
- Callback function.
116
-
117
- thisArg: any (optional)
118
- Callback execution context.
119
-
120
- Returns
121
- -------
122
- y: Array|TypedArray|Object
123
- Destination array/collection.
124
-
125
- Examples
126
- --------
127
- // Standard usage:
128
- > var x = [ -1.0, -2.0, -3.0, -4.0 ];
129
- > var y = [ 0.0, 0.0, 0.0, 0.0 ];
130
- > function clbk( v ) { return v; };
131
- > {{alias}}.ndarray( x.length, x, 1, 0, y, 1, 0, clbk )
132
- [ 1.0, 4.0, 9.0, 16.0 ]
133
-
134
- // Advanced indexing:
135
- > x = [ -1.0, -2.0, -3.0, -4.0 ];
136
- > y = [ 0.0, 0.0, 0.0, 0.0 ];
137
- > {{alias}}.ndarray( 2, x, 2, 1, y, -1, y.length-1, clbk )
138
- [ 0.0, 0.0, 16.0, 4.0 ]
139
-
140
- See Also
141
- --------
142
-
@@ -1,279 +0,0 @@
1
- /*
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2021 The Stdlib Authors.
5
- *
6
- * Licensed under the Apache License, Version 2.0 (the "License");
7
- * you may not use this file except in compliance with the License.
8
- * You may obtain a copy of the License at
9
- *
10
- * http://www.apache.org/licenses/LICENSE-2.0
11
- *
12
- * Unless required by applicable law or agreed to in writing, software
13
- * distributed under the License is distributed on an "AS IS" BASIS,
14
- * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15
- * See the License for the specific language governing permissions and
16
- * limitations under the License.
17
- */
18
-
19
- import abs2By = require( './index' );
20
-
21
- /**
22
- * Accessor callback.
23
- *
24
- * @returns accessed value
25
- */
26
- function accessor(): number {
27
- return 0.0;
28
- }
29
-
30
-
31
- // TESTS //
32
-
33
- // The function returns a collection...
34
- {
35
- const x = new Float64Array( 10 );
36
- const y = new Float64Array( 10 );
37
-
38
- abs2By( x.length, x, 1, y, 1, accessor ); // $ExpectType Collection
39
- abs2By( x.length, x, 1, y, 1, accessor, {} ); // $ExpectType Collection
40
- }
41
-
42
- // The compiler throws an error if the function is provided a first argument which is not a number...
43
- {
44
- const x = new Float64Array( 10 );
45
- const y = new Float64Array( 10 );
46
-
47
- abs2By( '10', x, 1, y, 1, accessor ); // $ExpectError
48
- abs2By( true, x, 1, y, 1, accessor ); // $ExpectError
49
- abs2By( false, x, 1, y, 1, accessor ); // $ExpectError
50
- abs2By( null, x, 1, y, 1, accessor ); // $ExpectError
51
- abs2By( undefined, x, 1, y, 1, accessor ); // $ExpectError
52
- abs2By( [], x, 1, y, 1, accessor ); // $ExpectError
53
- abs2By( {}, x, 1, y, 1, accessor ); // $ExpectError
54
- abs2By( ( x: number ): number => x, x, 1, y, 1, accessor ); // $ExpectError
55
- }
56
-
57
- // The compiler throws an error if the function is provided a second argument which is not a collection...
58
- {
59
- const x = new Float64Array( 10 );
60
- const y = new Float64Array( 10 );
61
-
62
- abs2By( x.length, 10, 1, y, 1, accessor ); // $ExpectError
63
- abs2By( x.length, true, 1, y, 1, accessor ); // $ExpectError
64
- abs2By( x.length, false, 1, y, 1, accessor ); // $ExpectError
65
- abs2By( x.length, null, 1, y, 1, accessor ); // $ExpectError
66
- abs2By( x.length, undefined, 1, y, 1, accessor ); // $ExpectError
67
- abs2By( x.length, {}, 1, y, 1, accessor ); // $ExpectError
68
- }
69
-
70
- // The compiler throws an error if the function is provided a third argument which is not a number...
71
- {
72
- const x = new Float64Array( 10 );
73
- const y = new Float64Array( 10 );
74
-
75
- abs2By( x.length, x, '10', y, 1, accessor ); // $ExpectError
76
- abs2By( x.length, x, true, y, 1, accessor ); // $ExpectError
77
- abs2By( x.length, x, false, y, 1, accessor ); // $ExpectError
78
- abs2By( x.length, x, null, y, 1, accessor ); // $ExpectError
79
- abs2By( x.length, x, undefined, y, 1, accessor ); // $ExpectError
80
- abs2By( x.length, x, [], y, 1, accessor ); // $ExpectError
81
- abs2By( x.length, x, {}, y, 1, accessor ); // $ExpectError
82
- abs2By( x.length, x, ( x: number ): number => x, y, 1, accessor ); // $ExpectError
83
- }
84
-
85
- // The compiler throws an error if the function is provided a fourth argument which is not a collection...
86
- {
87
- const x = new Float64Array( 10 );
88
-
89
- abs2By( x.length, x, 1, 10, 1, accessor ); // $ExpectError
90
- abs2By( x.length, x, 1, true, 1, accessor ); // $ExpectError
91
- abs2By( x.length, x, 1, false, 1, accessor ); // $ExpectError
92
- abs2By( x.length, x, 1, null, 1, accessor ); // $ExpectError
93
- abs2By( x.length, x, 1, undefined, 1, accessor ); // $ExpectError
94
- abs2By( x.length, x, 1, {}, 1, accessor ); // $ExpectError
95
- }
96
-
97
- // The compiler throws an error if the function is provided a fifth argument which is not a number...
98
- {
99
- const x = new Float64Array( 10 );
100
- const y = new Float64Array( 10 );
101
-
102
- abs2By( x.length, x, 1, y, '10', accessor ); // $ExpectError
103
- abs2By( x.length, x, 1, y, true, accessor ); // $ExpectError
104
- abs2By( x.length, x, 1, y, false, accessor ); // $ExpectError
105
- abs2By( x.length, x, 1, y, null, accessor ); // $ExpectError
106
- abs2By( x.length, x, 1, y, undefined, accessor ); // $ExpectError
107
- abs2By( x.length, x, 1, y, [], accessor ); // $ExpectError
108
- abs2By( x.length, x, 1, y, {}, accessor ); // $ExpectError
109
- abs2By( x.length, x, 1, y, ( x: number ): number => x, accessor ); // $ExpectError
110
- }
111
-
112
- // The compiler throws an error if the function is provided a sixth argument which is not a function...
113
- {
114
- const x = new Float64Array( 10 );
115
- const y = new Float64Array( 10 );
116
-
117
- abs2By( x.length, x, 1, y, 1, '10' ); // $ExpectError
118
- abs2By( x.length, x, 1, y, 1, 0 ); // $ExpectError
119
- abs2By( x.length, x, 1, y, 1, true ); // $ExpectError
120
- abs2By( x.length, x, 1, y, 1, false ); // $ExpectError
121
- abs2By( x.length, x, 1, y, 1, null ); // $ExpectError
122
- abs2By( x.length, x, 1, y, 1, undefined ); // $ExpectError
123
- abs2By( x.length, x, 1, y, 1, [] ); // $ExpectError
124
- abs2By( x.length, x, 1, y, 1, {} ); // $ExpectError
125
- }
126
-
127
- // The compiler throws an error if the function is provided an unsupported number of arguments...
128
- {
129
- const x = new Float64Array( 10 );
130
- const y = new Float64Array( 10 );
131
-
132
- abs2By(); // $ExpectError
133
- abs2By( x.length ); // $ExpectError
134
- abs2By( x.length, x ); // $ExpectError
135
- abs2By( x.length, x, 1 ); // $ExpectError
136
- abs2By( x.length, x, 1, y ); // $ExpectError
137
- abs2By( x.length, x, 1, y, 1 ); // $ExpectError
138
- abs2By( x.length, x, 1, y, 1, accessor, 10, 10 ); // $ExpectError
139
- }
140
-
141
- // Attached to main export is an `ndarray` method which returns a collection...
142
- {
143
- const x = new Float64Array( 10 );
144
- const y = new Float64Array( 10 );
145
-
146
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, accessor ); // $ExpectType Collection
147
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, accessor, {} ); // $ExpectType Collection
148
- }
149
-
150
- // The compiler throws an error if the `ndarray` method is provided a first argument which is not a number...
151
- {
152
- const x = new Float64Array( 10 );
153
- const y = new Float64Array( 10 );
154
-
155
- abs2By.ndarray( '10', x, 1, 0, y, 1, 0, accessor ); // $ExpectError
156
- abs2By.ndarray( true, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
157
- abs2By.ndarray( false, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
158
- abs2By.ndarray( null, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
159
- abs2By.ndarray( undefined, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
160
- abs2By.ndarray( [], x, 1, 0, y, 1, 0, accessor ); // $ExpectError
161
- abs2By.ndarray( {}, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
162
- abs2By.ndarray( ( x: number ): number => x, x, 1, 0, y, 1, 0, accessor ); // $ExpectError
163
- }
164
-
165
- // The compiler throws an error if the `ndarray` method is provided a second argument which is not a collection...
166
- {
167
- const x = new Float64Array( 10 );
168
- const y = new Float64Array( 10 );
169
-
170
- abs2By.ndarray( x.length, 10, 1, 0, y, 1, 0, accessor ); // $ExpectError
171
- abs2By.ndarray( x.length, true, 1, 0, y, 1, 0, accessor ); // $ExpectError
172
- abs2By.ndarray( x.length, false, 1, 0, y, 1, 0, accessor ); // $ExpectError
173
- abs2By.ndarray( x.length, null, 1, 0, y, 1, 0, accessor ); // $ExpectError
174
- abs2By.ndarray( x.length, undefined, 1, 0, y, 1, 0, accessor ); // $ExpectError
175
- abs2By.ndarray( x.length, {}, 1, 0, y, 1, 0, accessor ); // $ExpectError
176
- }
177
-
178
- // The compiler throws an error if the `ndarray` method is provided a third argument which is not a number...
179
- {
180
- const x = new Float64Array( 10 );
181
- const y = new Float64Array( 10 );
182
-
183
- abs2By.ndarray( x.length, x, '10', 0, y, 1, 0, accessor ); // $ExpectError
184
- abs2By.ndarray( x.length, x, true, 0, y, 1, 0, accessor ); // $ExpectError
185
- abs2By.ndarray( x.length, x, false, 0, y, 1, 0, accessor ); // $ExpectError
186
- abs2By.ndarray( x.length, x, null, 0, y, 1, 0, accessor ); // $ExpectError
187
- abs2By.ndarray( x.length, x, undefined, 0, y, 1, 0, accessor ); // $ExpectError
188
- abs2By.ndarray( x.length, x, [], 0, y, 1, 0, accessor ); // $ExpectError
189
- abs2By.ndarray( x.length, x, {}, 0, y, 1, 0, accessor ); // $ExpectError
190
- abs2By.ndarray( x.length, x, ( x: number ): number => x, 0, y, 1, 0, accessor ); // $ExpectError
191
- }
192
-
193
- // The compiler throws an error if the `ndarray` method is provided a fourth argument which is not a number...
194
- {
195
- const x = new Float64Array( 10 );
196
- const y = new Float64Array( 10 );
197
-
198
- abs2By.ndarray( x.length, x, 1, '10', y, 1, 0, accessor ); // $ExpectError
199
- abs2By.ndarray( x.length, x, 1, true, y, 1, 0, accessor ); // $ExpectError
200
- abs2By.ndarray( x.length, x, 1, false, y, 1, 0, accessor ); // $ExpectError
201
- abs2By.ndarray( x.length, x, 1, null, y, 1, 0, accessor ); // $ExpectError
202
- abs2By.ndarray( x.length, x, 1, undefined, y, 1, 0, accessor ); // $ExpectError
203
- abs2By.ndarray( x.length, x, 1, [], y, 1, 0, accessor ); // $ExpectError
204
- abs2By.ndarray( x.length, x, 1, {}, y, 1, 0, accessor ); // $ExpectError
205
- abs2By.ndarray( x.length, x, 1, ( x: number ): number => x, y, 1, 0, accessor ); // $ExpectError
206
- }
207
-
208
- // The compiler throws an error if the `ndarray` method is provided a fifth argument which is not a collection...
209
- {
210
- const x = new Float64Array( 10 );
211
-
212
- abs2By.ndarray( x.length, x, 1, 0, 10, 1, 0, accessor ); // $ExpectError
213
- abs2By.ndarray( x.length, x, 1, 0, true, 1, 0, accessor ); // $ExpectError
214
- abs2By.ndarray( x.length, x, 1, 0, false, 1, 0, accessor ); // $ExpectError
215
- abs2By.ndarray( x.length, x, 1, 0, null, 1, 0, accessor ); // $ExpectError
216
- abs2By.ndarray( x.length, x, 1, 0, undefined, 1, 0, accessor ); // $ExpectError
217
- abs2By.ndarray( x.length, x, 1, 0, {}, 1, 0, accessor ); // $ExpectError
218
- }
219
-
220
- // The compiler throws an error if the `ndarray` method is provided a sixth argument which is not a number...
221
- {
222
- const x = new Float64Array( 10 );
223
- const y = new Float64Array( 10 );
224
-
225
- abs2By.ndarray( x.length, x, 1, 0, y, '10', 0, accessor ); // $ExpectError
226
- abs2By.ndarray( x.length, x, 1, 0, y, true, 0, accessor ); // $ExpectError
227
- abs2By.ndarray( x.length, x, 1, 0, y, false, 0, accessor ); // $ExpectError
228
- abs2By.ndarray( x.length, x, 1, 0, y, null, 0, accessor ); // $ExpectError
229
- abs2By.ndarray( x.length, x, 1, 0, y, undefined, 0, accessor ); // $ExpectError
230
- abs2By.ndarray( x.length, x, 1, 0, y, [], 0, accessor ); // $ExpectError
231
- abs2By.ndarray( x.length, x, 1, 0, y, {}, 0, accessor ); // $ExpectError
232
- abs2By.ndarray( x.length, x, 1, 0, y, ( x: number ): number => x, 0, accessor ); // $ExpectError
233
- }
234
-
235
- // The compiler throws an error if the `ndarray` method is provided a seventh argument which is not a number...
236
- {
237
- const x = new Float64Array( 10 );
238
- const y = new Float64Array( 10 );
239
-
240
- abs2By.ndarray( x.length, x, 1, 0, y, 1, '10', accessor ); // $ExpectError
241
- abs2By.ndarray( x.length, x, 1, 0, y, 1, true, accessor ); // $ExpectError
242
- abs2By.ndarray( x.length, x, 1, 0, y, 1, false, accessor ); // $ExpectError
243
- abs2By.ndarray( x.length, x, 1, 0, y, 1, null, accessor ); // $ExpectError
244
- abs2By.ndarray( x.length, x, 1, 0, y, 1, undefined, accessor ); // $ExpectError
245
- abs2By.ndarray( x.length, x, 1, 0, y, 1, [], accessor ); // $ExpectError
246
- abs2By.ndarray( x.length, x, 1, 0, y, 1, {}, accessor ); // $ExpectError
247
- abs2By.ndarray( x.length, x, 1, 0, y, 1, ( x: number ): number => x, accessor ); // $ExpectError
248
- }
249
-
250
- // The compiler throws an error if the `ndarray` method is provided an eighth argument which is not a function...
251
- {
252
- const x = new Float64Array( 10 );
253
- const y = new Float64Array( 10 );
254
-
255
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, '10' ); // $ExpectError
256
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, 0 ); // $ExpectError
257
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, true ); // $ExpectError
258
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, false ); // $ExpectError
259
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, null ); // $ExpectError
260
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, undefined ); // $ExpectError
261
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, [] ); // $ExpectError
262
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, {} ); // $ExpectError
263
- }
264
-
265
- // The compiler throws an error if the `ndarray` method is provided an unsupported number of arguments...
266
- {
267
- const x = new Float64Array( 10 );
268
- const y = new Float64Array( 10 );
269
-
270
- abs2By.ndarray(); // $ExpectError
271
- abs2By.ndarray( x.length ); // $ExpectError
272
- abs2By.ndarray( x.length, x ); // $ExpectError
273
- abs2By.ndarray( x.length, x, 1 ); // $ExpectError
274
- abs2By.ndarray( x.length, x, 1, 0 ); // $ExpectError
275
- abs2By.ndarray( x.length, x, 1, 0, y ); // $ExpectError
276
- abs2By.ndarray( x.length, x, 1, 0, y, 1 ); // $ExpectError
277
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0 ); // $ExpectError
278
- abs2By.ndarray( x.length, x, 1, 0, y, 1, 0, accessor, 10, 10 ); // $ExpectError
279
- }