@stdlib/math-special-abs 0.2.1 → 0.3.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "@stdlib/math-special-abs",
3
- "version": "0.2.1",
4
- "description": "Compute the absolute value.",
3
+ "version": "0.3.0",
4
+ "description": "Compute the absolute value for each element in an ndarray.",
5
5
  "license": "Apache-2.0",
6
6
  "author": {
7
7
  "name": "The Stdlib Authors",
@@ -34,20 +34,23 @@
34
34
  "url": "https://github.com/stdlib-js/stdlib/issues"
35
35
  },
36
36
  "dependencies": {
37
- "@stdlib/math-base-special-abs": "^0.2.1",
38
- "@stdlib/math-base-special-absf": "^0.2.1",
39
- "@stdlib/math-base-special-identity": "^0.2.1",
40
- "@stdlib/math-base-special-labs": "^0.2.1",
41
- "@stdlib/math-strided-special-abs": "^0.2.1",
42
- "@stdlib/math-tools-unary": "^0.2.1",
43
- "@stdlib/ndarray-base-function-object": "^0.2.1",
44
- "@stdlib/ndarray-base-meta-data-props": "^0.2.1",
37
+ "@stdlib/math-base-special-abs": "^0.2.2",
38
+ "@stdlib/math-base-special-absf": "^0.2.2",
39
+ "@stdlib/math-base-special-cabs": "^0.2.2",
40
+ "@stdlib/math-base-special-cabsf": "^0.3.0",
41
+ "@stdlib/math-base-special-labs": "^0.2.2",
42
+ "@stdlib/math-tools-unary": "^0.2.2",
43
+ "@stdlib/ndarray-base-function-object": "^0.2.2",
44
+ "@stdlib/ndarray-base-meta-data-props": "^0.2.2",
45
45
  "@stdlib/ndarray-base-napi-unary": "^0.2.1",
46
- "@stdlib/ndarray-base-unary": "^0.2.1",
47
- "@stdlib/ndarray-dispatch": "^0.2.1",
48
- "@stdlib/ndarray-dtypes": "^0.2.1",
49
- "@stdlib/utils-library-manifest": "^0.2.1",
50
- "@stdlib/utils-try-require": "^0.2.1"
46
+ "@stdlib/ndarray-base-unary": "^0.3.0",
47
+ "@stdlib/ndarray-dispatch": "^0.2.2",
48
+ "@stdlib/ndarray-dtypes": "^0.4.0",
49
+ "@stdlib/number-uint16-base-identity": "^0.1.0",
50
+ "@stdlib/number-uint32-base-identity": "^0.1.0",
51
+ "@stdlib/number-uint8-base-identity": "^0.1.0",
52
+ "@stdlib/utils-library-manifest": "^0.2.3",
53
+ "@stdlib/utils-try-require": "^0.2.2"
51
54
  },
52
55
  "devDependencies": {},
53
56
  "engines": {
@@ -70,16 +73,15 @@
70
73
  "stdmath",
71
74
  "mathematics",
72
75
  "math",
73
- "math.abs",
76
+ "ndarray",
77
+ "elementwise",
78
+ "element-wise",
74
79
  "abs",
75
80
  "absolute",
76
81
  "magnitude",
77
82
  "value",
78
- "ndarray",
79
- "elementwise",
80
- "element-wise"
83
+ "math.abs"
81
84
  ],
82
- "__stdlib__": {},
83
85
  "funding": {
84
86
  "type": "opencollective",
85
87
  "url": "https://opencollective.com/stdlib"
package/src/addon.c CHANGED
@@ -19,42 +19,15 @@
19
19
  #include "stdlib/math/base/special/abs.h"
20
20
  #include "stdlib/math/base/special/absf.h"
21
21
  #include "stdlib/math/base/special/labs.h"
22
+ #include "stdlib/number/uint32/base/identity.h"
23
+ #include "stdlib/number/uint16/base/identity.h"
24
+ #include "stdlib/number/uint8/base/identity.h"
22
25
  #include "stdlib/ndarray/base/function_object.h"
23
26
  #include "stdlib/ndarray/base/napi/unary.h"
24
27
  #include "stdlib/ndarray/base/unary.h"
25
28
  #include "stdlib/ndarray/dtypes.h"
26
29
  #include <stdint.h>
27
30
 
28
- /**
29
- * Evaluates the identity function for an unsigned 32-bit integer.
30
- *
31
- * @param x input value
32
- * @return input value
33
- */
34
- static uint32_t identity_u( const uint32_t x ) {
35
- return x;
36
- }
37
-
38
- /**
39
- * Evaluates the identity function for an unsigned 16-bit integer.
40
- *
41
- * @param x input value
42
- * @return input value
43
- */
44
- static uint16_t identity_t( const uint16_t x ) {
45
- return x;
46
- }
47
-
48
- /**
49
- * Evaluates the identity function for an unsigned 8-bit integer.
50
- *
51
- * @param x input value
52
- * @return input value
53
- */
54
- static uint8_t identity_b( const uint8_t x ) {
55
- return x;
56
- }
57
-
58
31
  /**
59
32
  * Computes the absolute value of a signed 16-bit integer.
60
33
  *
@@ -250,35 +223,35 @@ static void *data[] = {
250
223
  (void *)abs_s,
251
224
 
252
225
  // uint32 (2)
253
- (void *)identity_u,
254
- (void *)identity_u,
226
+ (void *)stdlib_base_uint32_identity,
227
+ (void *)stdlib_base_uint32_identity,
255
228
 
256
229
  // uint16 (5)
257
- (void *)identity_t,
258
- (void *)identity_t,
259
- (void *)identity_t,
260
- (void *)identity_t,
261
- (void *)identity_t,
230
+ (void *)stdlib_base_uint16_identity,
231
+ (void *)stdlib_base_uint16_identity,
232
+ (void *)stdlib_base_uint16_identity,
233
+ (void *)stdlib_base_uint16_identity,
234
+ (void *)stdlib_base_uint16_identity,
262
235
 
263
236
  // uint8 (8)
264
- (void *)identity_b,
265
- (void *)identity_b,
266
- (void *)identity_b,
267
- (void *)identity_b,
268
- (void *)identity_b,
269
- (void *)identity_b,
270
- (void *)identity_b,
271
- (void *)identity_b,
237
+ (void *)stdlib_base_uint8_identity,
238
+ (void *)stdlib_base_uint8_identity,
239
+ (void *)stdlib_base_uint8_identity,
240
+ (void *)stdlib_base_uint8_identity,
241
+ (void *)stdlib_base_uint8_identity,
242
+ (void *)stdlib_base_uint8_identity,
243
+ (void *)stdlib_base_uint8_identity,
244
+ (void *)stdlib_base_uint8_identity,
272
245
 
273
246
  // uint8c (8)
274
- (void *)identity_b,
275
- (void *)identity_b,
276
- (void *)identity_b,
277
- (void *)identity_b,
278
- (void *)identity_b,
279
- (void *)identity_b,
280
- (void *)identity_b,
281
- (void *)identity_b
247
+ (void *)stdlib_base_uint8_identity,
248
+ (void *)stdlib_base_uint8_identity,
249
+ (void *)stdlib_base_uint8_identity,
250
+ (void *)stdlib_base_uint8_identity,
251
+ (void *)stdlib_base_uint8_identity,
252
+ (void *)stdlib_base_uint8_identity,
253
+ (void *)stdlib_base_uint8_identity,
254
+ (void *)stdlib_base_uint8_identity
282
255
  };
283
256
 
284
257
  // Create an ndarray function object:
@@ -1,50 +0,0 @@
1
- <svg xmlns:xlink="http://www.w3.org/1999/xlink" width="21.207ex" height="6.176ex" style="vertical-align: -2.505ex;" viewBox="0 -1580.7 9130.7 2659.1" role="img" focusable="false" xmlns="http://www.w3.org/2000/svg" aria-labelledby="MathJax-SVG-1-Title">
2
- <title id="MathJax-SVG-1-Title">StartAbsoluteValue x EndAbsoluteValue equals StartLayout Enlarged left-brace 1st Row 1st Column x 2nd Column if x greater-than-or-equal-to 0 2nd Row 1st Column negative x 2nd Column if x less-than 0 EndLayout</title>
3
- <defs aria-hidden="true">
4
- <path stroke-width="1" id="E1-MJMAIN-7C" d="M139 -249H137Q125 -249 119 -235V251L120 737Q130 750 139 750Q152 750 159 735V-235Q151 -249 141 -249H139Z"></path>
5
- <path stroke-width="1" id="E1-MJMATHI-78" d="M52 289Q59 331 106 386T222 442Q257 442 286 424T329 379Q371 442 430 442Q467 442 494 420T522 361Q522 332 508 314T481 292T458 288Q439 288 427 299T415 328Q415 374 465 391Q454 404 425 404Q412 404 406 402Q368 386 350 336Q290 115 290 78Q290 50 306 38T341 26Q378 26 414 59T463 140Q466 150 469 151T485 153H489Q504 153 504 145Q504 144 502 134Q486 77 440 33T333 -11Q263 -11 227 52Q186 -10 133 -10H127Q78 -10 57 16T35 71Q35 103 54 123T99 143Q142 143 142 101Q142 81 130 66T107 46T94 41L91 40Q91 39 97 36T113 29T132 26Q168 26 194 71Q203 87 217 139T245 247T261 313Q266 340 266 352Q266 380 251 392T217 404Q177 404 142 372T93 290Q91 281 88 280T72 278H58Q52 284 52 289Z"></path>
6
- <path stroke-width="1" id="E1-MJMAIN-3D" d="M56 347Q56 360 70 367H707Q722 359 722 347Q722 336 708 328L390 327H72Q56 332 56 347ZM56 153Q56 168 72 173H708Q722 163 722 153Q722 140 707 133H70Q56 140 56 153Z"></path>
7
- <path stroke-width="1" id="E1-MJMAIN-7B" d="M434 -231Q434 -244 428 -250H410Q281 -250 230 -184Q225 -177 222 -172T217 -161T213 -148T211 -133T210 -111T209 -84T209 -47T209 0Q209 21 209 53Q208 142 204 153Q203 154 203 155Q189 191 153 211T82 231Q71 231 68 234T65 250T68 266T82 269Q116 269 152 289T203 345Q208 356 208 377T209 529V579Q209 634 215 656T244 698Q270 724 324 740Q361 748 377 749Q379 749 390 749T408 750H428Q434 744 434 732Q434 719 431 716Q429 713 415 713Q362 710 332 689T296 647Q291 634 291 499V417Q291 370 288 353T271 314Q240 271 184 255L170 250L184 245Q202 239 220 230T262 196T290 137Q291 131 291 1Q291 -134 296 -147Q306 -174 339 -192T415 -213Q429 -213 431 -216Q434 -219 434 -231Z"></path>
8
- <path stroke-width="1" id="E1-MJMAIN-69" d="M69 609Q69 637 87 653T131 669Q154 667 171 652T188 609Q188 579 171 564T129 549Q104 549 87 564T69 609ZM247 0Q232 3 143 3Q132 3 106 3T56 1L34 0H26V46H42Q70 46 91 49Q100 53 102 60T104 102V205V293Q104 345 102 359T88 378Q74 385 41 385H30V408Q30 431 32 431L42 432Q52 433 70 434T106 436Q123 437 142 438T171 441T182 442H185V62Q190 52 197 50T232 46H255V0H247Z"></path>
9
- <path stroke-width="1" id="E1-MJMAIN-66" d="M273 0Q255 3 146 3Q43 3 34 0H26V46H42Q70 46 91 49Q99 52 103 60Q104 62 104 224V385H33V431H104V497L105 564L107 574Q126 639 171 668T266 704Q267 704 275 704T289 705Q330 702 351 679T372 627Q372 604 358 590T321 576T284 590T270 627Q270 647 288 667H284Q280 668 273 668Q245 668 223 647T189 592Q183 572 182 497V431H293V385H185V225Q185 63 186 61T189 57T194 54T199 51T206 49T213 48T222 47T231 47T241 46T251 46H282V0H273Z"></path>
10
- <path stroke-width="1" id="E1-MJMAIN-2265" d="M83 616Q83 624 89 630T99 636Q107 636 253 568T543 431T687 361Q694 356 694 346T687 331Q685 329 395 192L107 56H101Q83 58 83 76Q83 77 83 79Q82 86 98 95Q117 105 248 167Q326 204 378 228L626 346L360 472Q291 505 200 548Q112 589 98 597T83 616ZM84 -118Q84 -108 99 -98H678Q694 -104 694 -118Q694 -130 679 -138H98Q84 -131 84 -118Z"></path>
11
- <path stroke-width="1" id="E1-MJMAIN-30" d="M96 585Q152 666 249 666Q297 666 345 640T423 548Q460 465 460 320Q460 165 417 83Q397 41 362 16T301 -15T250 -22Q224 -22 198 -16T137 16T82 83Q39 165 39 320Q39 494 96 585ZM321 597Q291 629 250 629Q208 629 178 597Q153 571 145 525T137 333Q137 175 145 125T181 46Q209 16 250 16Q290 16 318 46Q347 76 354 130T362 333Q362 478 354 524T321 597Z"></path>
12
- <path stroke-width="1" id="E1-MJMAIN-2212" d="M84 237T84 250T98 270H679Q694 262 694 250T679 230H98Q84 237 84 250Z"></path>
13
- <path stroke-width="1" id="E1-MJMAIN-3C" d="M694 -11T694 -19T688 -33T678 -40Q671 -40 524 29T234 166L90 235Q83 240 83 250Q83 261 91 266Q664 540 678 540Q681 540 687 534T694 519T687 505Q686 504 417 376L151 250L417 124Q686 -4 687 -5Q694 -11 694 -19Z"></path>
14
- <path stroke-width="1" id="E1-MJSZ3-7B" d="M618 -943L612 -949H582L568 -943Q472 -903 411 -841T332 -703Q327 -682 327 -653T325 -350Q324 -28 323 -18Q317 24 301 61T264 124T221 171T179 205T147 225T132 234Q130 238 130 250Q130 255 130 258T131 264T132 267T134 269T139 272T144 275Q207 308 256 367Q310 436 323 519Q324 529 325 851Q326 1124 326 1154T332 1205Q369 1358 566 1443L582 1450H612L618 1444V1429Q618 1413 616 1411L608 1406Q599 1402 585 1393T552 1372T515 1343T479 1305T449 1257T429 1200Q425 1180 425 1152T423 851Q422 579 422 549T416 498Q407 459 388 424T346 364T297 318T250 284T214 264T197 254L188 251L205 242Q290 200 345 138T416 3Q421 -18 421 -48T423 -349Q423 -397 423 -472Q424 -677 428 -694Q429 -697 429 -699Q434 -722 443 -743T465 -782T491 -816T519 -845T548 -868T574 -886T595 -899T610 -908L616 -910Q618 -912 618 -928V-943Z"></path>
15
- </defs>
16
- <g stroke="currentColor" fill="currentColor" stroke-width="0" transform="matrix(1 0 0 -1 0 0)" aria-hidden="true">
17
- <use xlink:href="#E1-MJMAIN-7C" x="0" y="0"></use>
18
- <use xlink:href="#E1-MJMATHI-78" x="278" y="0"></use>
19
- <use xlink:href="#E1-MJMAIN-7C" x="851" y="0"></use>
20
- <use xlink:href="#E1-MJMAIN-3D" x="1407" y="0"></use>
21
- <g transform="translate(2463,0)">
22
- <use xlink:href="#E1-MJSZ3-7B"></use>
23
- <g transform="translate(917,0)">
24
- <g transform="translate(-11,0)">
25
- <use xlink:href="#E1-MJMATHI-78" x="0" y="550"></use>
26
- <g transform="translate(0,-650)">
27
- <use xlink:href="#E1-MJMAIN-2212" x="0" y="0"></use>
28
- <use xlink:href="#E1-MJMATHI-78" x="778" y="0"></use>
29
- </g>
30
- </g>
31
- <g transform="translate(2340,0)">
32
- <g transform="translate(0,550)">
33
- <use xlink:href="#E1-MJMAIN-69"></use>
34
- <use xlink:href="#E1-MJMAIN-66" x="278" y="0"></use>
35
- <use xlink:href="#E1-MJMATHI-78" x="835" y="0"></use>
36
- <use xlink:href="#E1-MJMAIN-2265" x="1685" y="0"></use>
37
- <use xlink:href="#E1-MJMAIN-30" x="2741" y="0"></use>
38
- </g>
39
- <g transform="translate(0,-650)">
40
- <use xlink:href="#E1-MJMAIN-69"></use>
41
- <use xlink:href="#E1-MJMAIN-66" x="278" y="0"></use>
42
- <use xlink:href="#E1-MJMATHI-78" x="835" y="0"></use>
43
- <use xlink:href="#E1-MJMAIN-3C" x="1685" y="0"></use>
44
- <use xlink:href="#E1-MJMAIN-30" x="2741" y="0"></use>
45
- </g>
46
- </g>
47
- </g>
48
- </g>
49
- </g>
50
- </svg>
package/include.gypi DELETED
@@ -1,53 +0,0 @@
1
- # @license Apache-2.0
2
- #
3
- # Copyright (c) 2021 The Stdlib Authors.
4
- #
5
- # Licensed under the Apache License, Version 2.0 (the "License");
6
- # you may not use this file except in compliance with the License.
7
- # You may obtain a copy of the License at
8
- #
9
- # http://www.apache.org/licenses/LICENSE-2.0
10
- #
11
- # Unless required by applicable law or agreed to in writing, software
12
- # distributed under the License is distributed on an "AS IS" BASIS,
13
- # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14
- # See the License for the specific language governing permissions and
15
- # limitations under the License.
16
-
17
- # A GYP include file for building a Node.js native add-on.
18
- #
19
- # Main documentation:
20
- #
21
- # [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
22
- # [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
23
- {
24
- # Define variables to be used throughout the configuration for all targets:
25
- 'variables': {
26
- # Source directory:
27
- 'src_dir': './src',
28
-
29
- # Include directories:
30
- 'include_dirs': [
31
- '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).include; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
32
- ],
33
-
34
- # Add-on destination directory:
35
- 'addon_output_dir': './src',
36
-
37
- # Source files:
38
- 'src_files': [
39
- '<(src_dir)/addon.c',
40
- '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).src; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
41
- ],
42
-
43
- # Library dependencies:
44
- 'libraries': [
45
- '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libraries; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
46
- ],
47
-
48
- # Library directories:
49
- 'library_dirs': [
50
- '<!@(node -e "var arr = require(\'@stdlib/utils-library-manifest\')(\'./manifest.json\',{},{\'basedir\':process.cwd(),\'paths\':\'posix\'}).libpath; for ( var i = 0; i < arr.length; i++ ) { console.log( arr[ i ] ); }")',
51
- ],
52
- }, # end variables
53
- }
package/lib/abs.js DELETED
@@ -1,79 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 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
- 'use strict';
20
-
21
- // MODULES //
22
-
23
- var dispatch = require( '@stdlib/math-tools-unary' );
24
- var config = require( './config.json' );
25
- var table = require( './table.js' );
26
-
27
-
28
- // MAIN //
29
-
30
- /**
31
- * Computes the absolute value.
32
- *
33
- * @name abs
34
- * @type {Function}
35
- * @param {(ndarray|Collection|number)} x - input value
36
- * @param {Options} [options] - options
37
- * @param {string} [options.order] - output array order
38
- * @param {string} [options.dtype] - output array dtype
39
- * @throws {TypeError} first argument must be a supported data type
40
- * @throws {TypeError} options argument must be an object
41
- * @throws {TypeError} must provide valid options
42
- * @returns {(ndarray|Collection|number)} results
43
- *
44
- * @example
45
- * var y = abs( -1.0 );
46
- * // returns 1.0
47
- *
48
- * @example
49
- * var Float64Array = require( '@stdlib/array-float64' );
50
- *
51
- * var x = new Float64Array( [ 1.0, -1.0, 0.0 ] );
52
- *
53
- * var y = abs( x );
54
- * // returns <Float64Array>[ 1.0, 1.0, 0.0 ]
55
- *
56
- * @example
57
- * var x = [ 1.0, -1.0, 0.0 ];
58
- *
59
- * var y = abs( x );
60
- * // returns [ 1.0, 1.0, 0.0 ]
61
- *
62
- * @example
63
- * var array = require( '@stdlib/ndarray-array' );
64
- *
65
- * var x = array( [ [ 1.0, -2.0 ], [ -3.0, 4.0 ] ] );
66
- * // returns <ndarray>
67
- *
68
- * var y = abs( x );
69
- * // returns <ndarray>
70
- *
71
- * var v = y.get( 0, 1 );
72
- * // 2.0
73
- */
74
- var abs = dispatch( table, config );
75
-
76
-
77
- // EXPORTS //
78
-
79
- module.exports = abs;
package/lib/abs.native.js DELETED
@@ -1,79 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 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
- 'use strict';
20
-
21
- // MODULES //
22
-
23
- var dispatch = require( '@stdlib/math-tools-unary' );
24
- var config = require( './config.json' );
25
- var table = require( './table.native.js' );
26
-
27
-
28
- // MAIN //
29
-
30
- /**
31
- * Computes the absolute value.
32
- *
33
- * @name abs
34
- * @type {Function}
35
- * @param {(ndarray|Collection|number)} x - input value
36
- * @param {Options} [options] - options
37
- * @param {string} [options.order] - output array order
38
- * @param {string} [options.dtype] - output array dtype
39
- * @throws {TypeError} first argument must be a supported data type
40
- * @throws {TypeError} options argument must be an object
41
- * @throws {TypeError} must provide valid options
42
- * @returns {(ndarray|Collection|number)} results
43
- *
44
- * @example
45
- * var y = abs( -1.0 );
46
- * // returns 1.0
47
- *
48
- * @example
49
- * var Float64Array = require( '@stdlib/array-float64' );
50
- *
51
- * var x = new Float64Array( [ 1.0, -1.0, 0.0 ] );
52
- *
53
- * var y = abs( x );
54
- * // returns <Float64Array>[ 1.0, 1.0, 0.0 ]
55
- *
56
- * @example
57
- * var x = [ 1.0, -1.0, 0.0 ];
58
- *
59
- * var y = abs( x );
60
- * // returns [ 1.0, 1.0, 0.0 ]
61
- *
62
- * @example
63
- * var array = require( '@stdlib/ndarray-array' );
64
- *
65
- * var x = array( [ [ 1.0, -2.0 ], [ -3.0, 4.0 ] ] );
66
- * // returns <ndarray>
67
- *
68
- * var y = abs( x );
69
- * // returns <ndarray>
70
- *
71
- * var v = y.get( 0, 1 );
72
- * // 2.0
73
- */
74
- var abs = dispatch( table, config );
75
-
76
-
77
- // EXPORTS //
78
-
79
- module.exports = abs;
package/lib/config.json DELETED
@@ -1,3 +0,0 @@
1
- {
2
- "output_dtype_policy": "same"
3
- }
package/lib/meta.json DELETED
@@ -1,5 +0,0 @@
1
- {
2
- "nargs": 2,
3
- "nin": 1,
4
- "nout": 1
5
- }
@@ -1,65 +0,0 @@
1
- /**
2
- * @license Apache-2.0
3
- *
4
- * Copyright (c) 2020 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
- 'use strict';
20
-
21
- // MODULES //
22
-
23
- var isTypedArrayLike = require( '@stdlib/assert-is-typed-array-like' );
24
- var serialize = require( '@stdlib/ndarray-base-serialize-meta-data' );
25
- var addon = require( './../src/addon.node' );
26
- var TABLE = require( './table.js' );
27
-
28
-
29
- // VARIABLES //
30
-
31
- var js = TABLE.ndarray;
32
- var table = {
33
- 'number': TABLE.number,
34
- 'complex': TABLE.complex,
35
- 'array': TABLE.array,
36
- 'ndarray': unary
37
- };
38
-
39
-
40
- // FUNCTIONS //
41
-
42
- /**
43
- * Applies a unary function to an input ndarray and assigns results to an output ndarray.
44
- *
45
- * @private
46
- * @param {ndarray} x - input array
47
- * @param {ndarray} y - output array
48
- * @returns {ndarray} output array
49
- */
50
- function unary( x, y ) {
51
- var xdata = x.data;
52
- var ydata = y.data;
53
-
54
- // WARNING: we assume that, if we're provided something which has a data buffer resembling a typed array, we're provided a typed ndarray buffer; however, this can lead to potential unintended errors as the native add-on cannot work with non-typed array objects (e.g., generic arrays)...
55
- if ( !( isTypedArrayLike( xdata ) && isTypedArrayLike( ydata ) ) ) {
56
- return js( x, y );
57
- }
58
- addon( xdata, serialize( x ), ydata, serialize( y ) );
59
- return y;
60
- }
61
-
62
-
63
- // EXPORTS //
64
-
65
- module.exports = table;