Skip to content

Commit 6e69af4

Browse files
refactor: update math/base/special/cexp to follow latest project conventions
PR-URL: #3394 Closes: #3393 Co-authored-by: Gunj Joshi <[email protected]> Reviewed-by: Gunj Joshi <[email protected]> Signed-off-by: Gunj Joshi <[email protected]>
1 parent 12a3dbf commit 6e69af4

File tree

2 files changed

+44
-16
lines changed

2 files changed

+44
-16
lines changed

lib/node_modules/@stdlib/math/base/special/cexp/manifest.json

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,14 @@
3838
"dependencies": [
3939
"@stdlib/math/base/napi/unary",
4040
"@stdlib/complex/float64/ctor",
41-
"@stdlib/complex/float64/reim"
41+
"@stdlib/complex/float64/reim",
42+
"@stdlib/math/base/special/exp",
43+
"@stdlib/math/base/special/sincos",
44+
"@stdlib/math/base/assert/is-nan",
45+
"@stdlib/math/base/assert/is-infinite",
46+
"@stdlib/math/base/special/copysign",
47+
"@stdlib/constants/float64/pinf",
48+
"@stdlib/constants/float64/ninf"
4249
]
4350
},
4451
{
@@ -53,7 +60,14 @@
5360
"libpath": [],
5461
"dependencies": [
5562
"@stdlib/complex/float64/ctor",
56-
"@stdlib/complex/float64/reim"
63+
"@stdlib/complex/float64/reim",
64+
"@stdlib/math/base/special/exp",
65+
"@stdlib/math/base/special/sincos",
66+
"@stdlib/math/base/assert/is-nan",
67+
"@stdlib/math/base/assert/is-infinite",
68+
"@stdlib/math/base/special/copysign",
69+
"@stdlib/constants/float64/pinf",
70+
"@stdlib/constants/float64/ninf"
5771
]
5872
},
5973
{
@@ -68,7 +82,14 @@
6882
"libpath": [],
6983
"dependencies": [
7084
"@stdlib/complex/float64/ctor",
71-
"@stdlib/complex/float64/reim"
85+
"@stdlib/complex/float64/reim",
86+
"@stdlib/math/base/special/exp",
87+
"@stdlib/math/base/special/sincos",
88+
"@stdlib/math/base/assert/is-nan",
89+
"@stdlib/math/base/assert/is-infinite",
90+
"@stdlib/math/base/special/copysign",
91+
"@stdlib/constants/float64/pinf",
92+
"@stdlib/constants/float64/ninf"
7293
]
7394
}
7495
]

lib/node_modules/@stdlib/math/base/special/cexp/src/main.c

Lines changed: 20 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -17,9 +17,15 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/cexp.h"
20+
#include "stdlib/math/base/special/exp.h"
21+
#include "stdlib/math/base/special/sincos.h"
22+
#include "stdlib/math/base/assert/is_nan.h"
23+
#include "stdlib/math/base/assert/is_infinite.h"
24+
#include "stdlib/constants/float64/pinf.h"
25+
#include "stdlib/math/base/special/copysign.h"
26+
#include "stdlib/constants/float64/ninf.h"
2027
#include "stdlib/complex/float64/ctor.h"
2128
#include "stdlib/complex/float64/reim.h"
22-
#include <math.h>
2329

2430
/**
2531
* Evaluates the exponential function of a double-precision complex floating-point number.
@@ -48,27 +54,28 @@ stdlib_complex128_t stdlib_base_cexp( const stdlib_complex128_t z ) {
4854

4955
stdlib_complex128_reim( z, &re, &im );
5056

51-
if ( isnan( re ) ){
52-
re = NAN;
57+
if ( stdlib_base_is_nan( re ) ) {
58+
re = 0.0 / 0.0; // NaN
5359
im = ( im == 0.0 ) ? im : re;
54-
} else if ( isinf( im ) ){
55-
if ( re == INFINITY ) {
60+
} else if ( stdlib_base_is_infinite( im ) ) {
61+
if ( re == STDLIB_CONSTANT_FLOAT64_PINF ) {
5662
re = -re;
57-
im = NAN;
58-
} else if ( re == -INFINITY ) {
63+
im = 0.0 / 0.0; // NaN
64+
} else if ( re == STDLIB_CONSTANT_FLOAT64_NINF ) {
5965
re = -0.0;
60-
im = copysign( 0.0, im );
66+
im = stdlib_base_copysign( 0.0, im );
6167
} else {
62-
re = NAN;
63-
im = NAN;
68+
re = 0.0 / 0.0; // NaN
69+
im = 0.0 / 0.0; // NaN
6470
}
6571
} else {
66-
e = exp( re );
72+
e = stdlib_base_exp( re );
6773
if ( im == 0.0 ) {
6874
re = e;
6975
} else {
70-
re = cos( im ) * e;
71-
im = sin( im ) * e;
76+
stdlib_base_sincos( im, &im, &re );
77+
re *= e;
78+
im *= e;
7279
}
7380
}
7481
return stdlib_complex128( re, im );

0 commit comments

Comments
 (0)