Skip to content

Commit

Permalink
refactor: use stdlib APIs and adjust test tolerances
Browse files Browse the repository at this point in the history
  • Loading branch information
kgryte committed Jul 17, 2024
1 parent ecb9b5a commit 0d796b2
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 8 deletions.
12 changes: 9 additions & 3 deletions lib/node_modules/@stdlib/math/base/special/ccis/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -39,7 +39,9 @@
"@stdlib/math/base/napi/unary",
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/exp"
"@stdlib/math/base/special/exp",
"@stdlib/math/base/special/cos",
"@stdlib/math/base/special/sin"
]
},
{
Expand All @@ -55,7 +57,9 @@
"dependencies": [
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/exp"
"@stdlib/math/base/special/exp",
"@stdlib/math/base/special/cos",
"@stdlib/math/base/special/sin"
]
},
{
Expand All @@ -71,7 +75,9 @@
"dependencies": [
"@stdlib/complex/float64/ctor",
"@stdlib/complex/float64/reim",
"@stdlib/math/base/special/exp"
"@stdlib/math/base/special/exp",
"@stdlib/math/base/special/cos",
"@stdlib/math/base/special/sin"
]
}
]
Expand Down
9 changes: 5 additions & 4 deletions lib/node_modules/@stdlib/math/base/special/ccis/src/main.c
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,8 @@
#include "stdlib/complex/float64/ctor.h"
#include "stdlib/complex/float64/reim.h"
#include "stdlib/math/base/special/exp.h"
#include <math.h>

#include "stdlib/math/base/special/sin.h"
#include "stdlib/math/base/special/cos.h"

/**
* Evaluates the cis function for a double-precision complex floating-point number.
Expand Down Expand Up @@ -68,8 +68,9 @@ stdlib_complex128_t stdlib_base_ccis( const stdlib_complex128_t z ) {

stdlib_complex128_reim( z, &re, &im );

y = sin( re ); //TODO: use stdlib function once available
x = cos( re ); //TODO: use stdlib function once available
// TODO: replace with stdlib/math/base/special/sincos
y = stdlib_base_sin( re );
x = stdlib_base_cos( re );
if( im != 0.0 ){
e = stdlib_base_exp( -im );
y *= e;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -129,8 +129,9 @@ tape( 'the function computes cis(z) for complex z', opts, function test( t ) {
if ( real( q ) === cisre[ i ] ) {
t.strictEqual( real( q ), cisre[ i ], 'returns expected real component' );
} else {
// NOTE: the results may differ slightly from the reference and JavaScript implementations due to compiler optimizations which may be performed resulting in result divergence. For discussion, see https://github.com/stdlib-js/stdlib/pull/2298#discussion_r1624765205
delta = abs( real( q ) - cisre[ i ] );
tol = EPS * abs( cisre[ i ] );
tol = 1.05 * EPS * abs( cisre[ i ] );
t.ok( delta <= tol, 'within tolerance. z: '+re[i]+'+ '+im[i]+'i. real: '+real( q )+'. expected: '+cisre[i]+'. delta: '+delta+'. tol: '+tol+'.' );
}
if ( imag( q ) === cisim[ i ] ) {
Expand Down

1 comment on commit 0d796b2

@stdlib-bot
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Coverage Report

Package Statements Branches Functions Lines
blas/base/dger $\color{red}400/437$
$\color{green}+91.53\%$
$\color{green}9/9$
$\color{green}+100.00\%$
$\color{red}0/4$
$\color{green}+0.00\%$
$\color{red}400/437$
$\color{green}+91.53\%$
math/base/special/ccis $\color{green}246/246$
$\color{green}+100.00\%$
$\color{green}6/6$
$\color{green}+100.00\%$
$\color{green}2/2$
$\color{green}+100.00\%$
$\color{green}246/246$
$\color{green}+100.00\%$

The above coverage report was generated for the changes in this push.

Please sign in to comment.