@stdlib/math-strided-special-abs2-by 0.0.7 → 0.1.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/CITATION.cff ADDED
@@ -0,0 +1,30 @@
1
+ cff-version: 1.2.0
2
+ title: stdlib
3
+ message: >-
4
+ If you use this software, please cite it using the
5
+ metadata from this file.
6
+
7
+ type: software
8
+
9
+ authors:
10
+ - name: The Stdlib Authors
11
+ url: https://github.com/stdlib-js/stdlib/graphs/contributors
12
+
13
+ repository-code: https://github.com/stdlib-js/stdlib
14
+ url: https://stdlib.io
15
+
16
+ abstract: |
17
+ Standard library for JavaScript and Node.js.
18
+
19
+ keywords:
20
+ - JavaScript
21
+ - Node.js
22
+ - TypeScript
23
+ - standard library
24
+ - scientific computing
25
+ - numerical computing
26
+ - statistical computing
27
+
28
+ license: Apache-2.0 AND BSL-1.0
29
+
30
+ date-released: 2016
package/LICENSE CHANGED
@@ -175,307 +175,3 @@
175
175
  of your accepting any such warranty or additional liability.
176
176
 
177
177
  END OF TERMS AND CONDITIONS
178
-
179
-
180
-
181
- Boost Software License - Version 1.0 - August 17th, 2003
182
-
183
- Permission is hereby granted, free of charge, to any person or organization
184
- obtaining a copy of the software and accompanying documentation covered by this
185
- license (the "Software") to use, reproduce, display, distribute, execute, and
186
- transmit the Software, and to prepare derivative works of the Software, and to
187
- permit third-parties to whom the Software is furnished to do so, all subject to
188
- the following:
189
-
190
- The copyright notices in the Software and this entire statement, including the
191
- above license grant, this restriction and the following disclaimer, must be
192
- included in all copies of the Software, in whole or in part, and all derivative
193
- works of the Software, unless such copies or derivative works are solely in the
194
- form of machine-executable object code generated by a source language processor.
195
-
196
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
197
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
198
- FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT SHALL THE
199
- COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE FOR ANY DAMAGES
200
- OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF
201
- OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
202
-
203
-
204
-
205
-
206
- DEPENDENCIES
207
-
208
- The library links against the following external libraries, which have their own
209
- licenses:
210
-
211
- * OpenBLAS <https://raw.githubusercontent.com/xianyi/OpenBLAS/
212
- def146efed8d5908ea04e22668feeab7099599a0/LICENSE>
213
-
214
- Copyright (c) 2011-2014, The OpenBLAS Project
215
- All rights reserved.
216
-
217
- Redistribution and use in source and binary forms, with or without
218
- modification, are permitted provided that the following conditions are
219
- met:
220
-
221
- 1. Redistributions of source code must retain the above copyright
222
- notice, this list of conditions and the following disclaimer.
223
-
224
- 2. Redistributions in binary form must reproduce the above copyright
225
- notice, this list of conditions and the following disclaimer in
226
- the documentation and/or other materials provided with the
227
- distribution.
228
-
229
- 3. Neither the name of the OpenBLAS project nor the names of
230
- its contributors may be used to endorse or promote products
231
- derived from this software without specific prior written
232
- permission.
233
-
234
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
235
- AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
236
- IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
237
- ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE
238
- LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
239
- CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE
240
- GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
241
- HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
242
- LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF
243
- THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
244
-
245
-
246
- * Electron <https://raw.githubusercontent.com/electron/electron/
247
- c4cfb3e7110266b9d7ad80e1ae097c4db564501c/LICENSE>
248
-
249
- Copyright (c) 2013-2017 GitHub Inc.
250
-
251
- Permission is hereby granted, free of charge, to any person obtaining
252
- a copy of this software and associated documentation files (the
253
- "Software"), to deal in the Software without restriction, including
254
- without limitation the rights to use, copy, modify, merge, publish,
255
- distribute, sublicense, and/or sell copies of the Software, and to
256
- permit persons to whom the Software is furnished to do so, subject to
257
- the following conditions:
258
-
259
- The above copyright notice and this permission notice shall be
260
- included in all copies or substantial portions of the Software.
261
-
262
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
263
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
264
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
265
- NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
266
- LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
267
- OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
268
- WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
269
-
270
-
271
- * Boost <http://www.boost.org/LICENSE_1_0.txt>
272
-
273
- Boost Software License - Version 1.0 - August 17th, 2003
274
-
275
- Permission is hereby granted, free of charge, to any person or organization
276
- obtaining a copy of the software and accompanying documentation covered by
277
- this license (the "Software") to use, reproduce, display, distribute,
278
- execute, and transmit the Software, and to prepare derivative works of the
279
- Software, and to permit third-parties to whom the Software is furnished to
280
- do so, all subject to the following:
281
-
282
- The copyright notices in the Software and this entire statement, including
283
- the above license grant, this restriction and the following disclaimer,
284
- must be included in all copies of the Software, in whole or in part, and
285
- all derivative works of the Software, unless such copies or derivative
286
- works are solely in the form of machine-executable object code generated by
287
- a source language processor.
288
-
289
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
290
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
291
- FITNESS FOR A PARTICULAR PURPOSE, TITLE AND NON-INFRINGEMENT. IN NO EVENT
292
- SHALL THE COPYRIGHT HOLDERS OR ANYONE DISTRIBUTING THE SOFTWARE BE LIABLE
293
- FOR ANY DAMAGES OR OTHER LIABILITY, WHETHER IN CONTRACT, TORT OR OTHERWISE,
294
- ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
295
- DEALINGS IN THE SOFTWARE.
296
-
297
-
298
- * Cephes <http://www.netlib.org/cephes/readme>
299
-
300
- Copyright (c) 1984-2000 Stephen L. Moshier
301
-
302
- Some software in this archive may be from the book _Methods and Programs for
303
- Mathematical Functions_ (Prentice-Hall or Simon & Schuster International, 1989)
304
- or from the Cephes Mathematical Library, a commercial product. In either event,
305
- it is copyrighted by the author. What you see here may be used freely but it
306
- comes with no support or guarantee.
307
-
308
- Stephen L. Moshier
309
- moshier@na-net.ornl.gov
310
-
311
-
312
-
313
- ATTRIBUTION
314
-
315
- The library contains implementations from the following external libraries,
316
- which have their own licenses:
317
-
318
- * FreeBSD <https://svnweb.freebsd.org/>
319
-
320
- Copyright (C) 1993-2004 by Sun Microsystems, Inc. All rights reserved.
321
-
322
- Developed at SunPro, a Sun Microsystems, Inc. business.
323
- Permission to use, copy, modify, and distribute this
324
- software is freely granted, provided that this notice
325
- is preserved.
326
-
327
-
328
- * FDLIBM <http://www.netlib.org/fdlibm/>
329
-
330
- Copyright (C) 2004 by Sun Microsystems, Inc. All rights reserved.
331
-
332
- Developed at SunPro, a Sun Microsystems, Inc. business.
333
- Permission to use, copy, modify, and distribute this
334
- software is freely granted, provided that this notice
335
- is preserved.
336
-
337
-
338
- * Go <https://raw.githubusercontent.com/golang/go/master/LICENSE>
339
-
340
- Copyright (c) 2009 The Go Authors. All rights reserved.
341
-
342
- Redistribution and use in source and binary forms, with or without
343
- modification, are permitted provided that the following conditions are
344
- met:
345
-
346
- * Redistributions of source code must retain the above copyright
347
- notice, this list of conditions and the following disclaimer.
348
- * Redistributions in binary form must reproduce the above
349
- copyright notice, this list of conditions and the following disclaimer
350
- in the documentation and/or other materials provided with the
351
- distribution.
352
- * Neither the name of Google Inc. nor the names of its
353
- contributors may be used to endorse or promote products derived from
354
- this software without specific prior written permission.
355
-
356
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
357
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
358
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
359
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
360
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
361
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
362
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
363
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
364
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
365
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
366
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
367
-
368
-
369
- * SLATEC Common Mathematical Library <http://www.netlib.no/netlib/slatec/>
370
-
371
- Public domain.
372
-
373
-
374
- * ESLint <https://raw.githubusercontent.com/eslint/eslint/master/LICENSE>
375
-
376
- Copyright JS Foundation and other contributors, https://js.foundation
377
-
378
- Permission is hereby granted, free of charge, to any person obtaining a copy
379
- of this software and associated documentation files (the "Software"), to deal
380
- in the Software without restriction, including without limitation the rights
381
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
382
- copies of the Software, and to permit persons to whom the Software is
383
- furnished to do so, subject to the following conditions:
384
-
385
- The above copyright notice and this permission notice shall be included in
386
- all copies or substantial portions of the Software.
387
-
388
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
389
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
390
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
391
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
392
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
393
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
394
- THE SOFTWARE.
395
-
396
-
397
- * StatsFuns.jl <https://raw.githubusercontent.com/JuliaStats/StatsFuns.jl/
398
- e66dd973650c375bc1739c820e5b96bb5bd000a8/LICENSE.md>
399
-
400
- Copyright (c) 2015: Dahua Lin.
401
-
402
- Permission is hereby granted, free of charge, to any person obtaining
403
- a copy of this software and associated documentation files (the
404
- "Software"), to deal in the Software without restriction, including
405
- without limitation the rights to use, copy, modify, merge, publish,
406
- distribute, sublicense, and/or sell copies of the Software, and to
407
- permit persons to whom the Software is furnished to do so, subject to
408
- the following conditions:
409
-
410
- The above copyright notice and this permission notice shall be
411
- included in all copies or substantial portions of the Software.
412
-
413
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
414
- EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
415
- MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.
416
- IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY
417
- CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT,
418
- TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE
419
- SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
420
-
421
-
422
- * SpecialFunctions.jl <https://raw.githubusercontent.com/JuliaMath/
423
- SpecialFunctions.jl/02a173fbe24a61c4b392aec17a9764ac5727feb1/LICENSE>
424
-
425
- The MIT License (MIT)
426
-
427
- Copyright (c) 2017 Jeff Bezanson, Stefan Karpinski, Viral B. Shah, and others:
428
-
429
- https://github.com/JuliaMath/SpecialFunctions.jl/graphs/contributors
430
-
431
- Permission is hereby granted, free of charge, to any person obtaining a copy
432
- of this software and associated documentation files (the "Software"), to deal
433
- in the Software without restriction, including without limitation the rights
434
- to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
435
- copies of the Software, and to permit persons to whom the Software is
436
- furnished to do so, subject to the following conditions:
437
-
438
- The above copyright notice and this permission notice shall be included in all
439
- copies or substantial portions of the Software.
440
-
441
- THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
442
- IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
443
- FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
444
- AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
445
- LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
446
- OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
447
- SOFTWARE.
448
-
449
-
450
- * MT19937 <http://www.math.sci.hiroshima-u.ac.jp/~m-mat/MT/MT2002/CODES/
451
- mt19937ar.c>
452
-
453
- Copyright (C) 1997 - 2002, Makoto Matsumoto and Takuji Nishimura,
454
- All rights reserved.
455
-
456
- Redistribution and use in source and binary forms, with or without
457
- modification, are permitted provided that the following conditions
458
- are met:
459
-
460
- 1. Redistributions of source code must retain the above copyright
461
- notice, this list of conditions and the following disclaimer.
462
-
463
- 2. Redistributions in binary form must reproduce the above copyright
464
- notice, this list of conditions and the following disclaimer in the
465
- documentation and/or other materials provided with the distribution.
466
-
467
- 3. The names of its contributors may not be used to endorse or promote
468
- products derived from this software without specific prior written
469
- permission.
470
-
471
- THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
472
- "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
473
- LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
474
- A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
475
- OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
476
- SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
477
- LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
478
- DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
479
- THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
480
- (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
481
- OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
package/NOTICE CHANGED
@@ -1 +1 @@
1
- Copyright (c) 2016-2022 The Stdlib Authors.
1
+ Copyright (c) 2016-2023 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-2023. 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
298
- [test-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml
305
+ [test-image]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml/badge.svg?branch=v0.1.0
306
+ [test-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/actions/workflows/test.yml?query=branch:v0.1.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
@@ -307,19 +315,20 @@ Copyright &copy; 2016-2022. The Stdlib [Authors][stdlib-authors].
307
315
 
308
316
  -->
309
317
 
318
+ [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
319
+ [chat-url]: https://app.gitter.im/#/room/#stdlib-js_stdlib:gitter.im
320
+
321
+ [stdlib]: https://github.com/stdlib-js/stdlib
322
+
323
+ [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
324
+
310
325
  [umd]: https://github.com/umdjs/umd
311
326
  [es-module]: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Guide/Modules
312
327
 
313
328
  [deno-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/deno
314
329
  [umd-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/umd
315
330
  [esm-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/tree/esm
316
-
317
- [chat-image]: https://img.shields.io/gitter/room/stdlib-js/stdlib.svg
318
- [chat-url]: https://gitter.im/stdlib-js/stdlib/
319
-
320
- [stdlib]: https://github.com/stdlib-js/stdlib
321
-
322
- [stdlib-authors]: https://github.com/stdlib-js/stdlib/graphs/contributors
331
+ [branches-url]: https://github.com/stdlib-js/math-strided-special-abs2-by/blob/main/branches.md
323
332
 
324
333
  [stdlib-license]: https://raw.githubusercontent.com/stdlib-js/math-strided-special-abs2-by/main/LICENSE
325
334
 
@@ -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.7",
3
+ "version": "0.1.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,22 @@
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.1.0",
41
+ "@stdlib/strided-base-map-by": "^0.1.0",
42
+ "@stdlib/types": "^0.1.0",
43
+ "@stdlib/utils-define-nonenumerable-read-only-property": "^0.1.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.0.6",
47
+ "@stdlib/array-filled-by": "^0.0.2",
48
+ "@stdlib/array-float64": "^0.1.0",
49
+ "@stdlib/bench": "^0.1.0",
50
+ "@stdlib/math-base-assert-is-nan": "^0.1.0",
51
+ "@stdlib/math-base-special-pow": "^0.1.0",
52
+ "@stdlib/random-base-uniform": "^0.0.6",
52
53
  "tape": "git+https://github.com/kgryte/tape.git#fix/globby",
53
54
  "istanbul": "^0.4.1",
54
- "tap-spec": "5.x.x"
55
+ "tap-min": "git+https://github.com/Planeshifter/tap-min.git"
55
56
  },
56
57
  "engines": {
57
58
  "node": ">=0.10.0",
@@ -92,7 +93,7 @@
92
93
  ],
93
94
  "__stdlib__": {},
94
95
  "funding": {
95
- "type": "patreon",
96
- "url": "https://www.patreon.com/athan"
96
+ "type": "opencollective",
97
+ "url": "https://opencollective.com/stdlib"
97
98
  }
98
99
  }
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
- }