Skip to content

Commit

Permalink
refactor: replace fabs with stdlib_base_abs in C implementation o…
Browse files Browse the repository at this point in the history
…f `blas/ext/base/dapxsumkbn`

PR-URL: stdlib-js#3214
Reviewed-by: Athan Reines <[email protected]>
Co-authored-by: stdlib-bot <[email protected]>
  • Loading branch information
headlessNode and stdlib-bot authored Nov 21, 2024
1 parent 49f4678 commit 4eb9aea
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,8 @@
"@stdlib/napi/argv-int64",
"@stdlib/napi/argv-double",
"@stdlib/napi/argv-strided-float64array",
"@stdlib/napi/create-double"
"@stdlib/napi/create-double",
"@stdlib/math/base/special/abs"
]
},
{
Expand All @@ -58,7 +59,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/special/abs"
]
},
{
Expand All @@ -73,7 +75,8 @@
"libpath": [],
"dependencies": [
"@stdlib/blas/base/shared",
"@stdlib/strided/base/stride2offset"
"@stdlib/strided/base/stride2offset",
"@stdlib/math/base/special/abs"
]
}
]
Expand Down
4 changes: 2 additions & 2 deletions lib/node_modules/@stdlib/blas/ext/base/dapxsumkbn/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -19,7 +19,7 @@
#include "stdlib/blas/ext/base/dapxsumkbn.h"
#include "stdlib/blas/base/shared.h"
#include "stdlib/strided/base/stride2offset.h"
#include <math.h>
#include "stdlib/math/base/special/abs.h"

/**
* Adds a scalar constant to each double-precision floating-point strided array element and computes the sum using an improved Kahan–Babuška algorithm.
Expand Down Expand Up @@ -72,7 +72,7 @@ double API_SUFFIX(stdlib_strided_dapxsumkbn_ndarray)( const CBLAS_INT N, const d
for ( i = 0; i < N; i++ ) {
v = alpha + X[ ix ];
t = sum + v;
if ( fabs( sum ) >= fabs( v ) ) {
if ( stdlib_base_abs( sum ) >= stdlib_base_abs( v ) ) {
c += (sum-t) + v;
} else {
c += (v-t) + sum;
Expand Down

0 comments on commit 4eb9aea

Please sign in to comment.