diff --git a/lib/node_modules/@stdlib/math/base/special/cexp/README.md b/lib/node_modules/@stdlib/math/base/special/cexp/README.md index da53b36fccd9..3ddd0e1c7bb7 100644 --- a/lib/node_modules/@stdlib/math/base/special/cexp/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cexp/README.md @@ -20,9 +20,9 @@ limitations under the License. # exp -> Compute the [exponential][exponential-function] function of a complex number. +> Evaluate the [exponential][exponential-function] function for a double-precision complex floating-point number. -
+
The [exponential][exponential-function] function of a complex number is defined as @@ -51,30 +51,32 @@ The [exponential][exponential-function] function of a complex number is defined var cexp = require( '@stdlib/math/base/special/cexp' ); ``` -#### cexp( \[out,] re, im ) +#### cexp( z ) -Evaluates the [exponential][exponential-function] function with a `complex` argument comprised of a **real** component `re` and an **imaginary** component `im`. +Evaluates the [exponential][exponential-function] function for a double-precision complex floating-point number. ```javascript -var v = cexp( 0.0, 0.0 ); -// returns [ 1.0, 0.0 ] +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); -v = cexp( 0.0, 1.0 ); -// returns [ ~0.540, ~0.841 ] -``` +var v = cexp( new Complex128( 0.0, 0.0 ) ); +// returns -By default, the function returns real and imaginary components as a two-element `array`. To avoid unnecessary memory allocation, the function supports providing an output (destination) object. +var re = real( v ); +// returns 1.0 -```javascript -var Float64Array = require( '@stdlib/array/float64' ); +var im = imag( v ); +// returns 0.0 -var out = new Float64Array( 2 ); +v = cexp( new Complex128( 0.0, 1.0 ) ); +// returns -var v = cexp( out, 0.0, 1.0 ); -// returns [ ~0.540, ~0.841 ] +re = real( v ); +// returns ~0.540 -var bool = ( v === out ); -// returns true +im = imag( v ); +// returns ~0.841 ```
@@ -89,28 +91,128 @@ var bool = ( v === out ); ```javascript var Complex128 = require( '@stdlib/complex/float64' ); -var randu = require( '@stdlib/random/base/randu' ); -var round = require( '@stdlib/math/base/special/round' ); -var real = require( '@stdlib/complex/real' ); -var imag = require( '@stdlib/complex/imag' ); +var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ); var cexp = require( '@stdlib/math/base/special/cexp' ); -var re; -var im; +function randomComplex() { + var re = discreteUniform( -50, 50 ); + var im = discreteUniform( -50, 50 ); + return new Complex128( re, im ); +} + var z1; var z2; -var o; var i; - for ( i = 0; i < 100; i++ ) { - re = round( randu()*100.0 ) - 50.0; - im = round( randu()*100.0 ) - 50.0; - z1 = new Complex128( re, im ); + z1 = randomComplex(); + z2 = cexp( z1 ); + console.log( 'cexp(%s) = %s', z1.toString(), z2.toString() ); +} +``` - o = cexp( real(z1), imag(z1) ); - z2 = new Complex128( o[ 0 ], o[ 1 ] ); +
- console.log( 'cexp(%s) = %s', z1.toString(), z2.toString() ); + + + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/cexp.h" +``` + +#### stdlib_base_cexp( z ) + +Evaluates the [exponential][exponential-function] function for a double-precision complex floating-point number. + +```c +#include "stdlib/complex/float64.h" +#include "stdlib/complex/real.h" +#include "stdlib/complex/imag.h" + +stdlib_complex128_t z = stdlib_complex128( 0.0, 0.0 ); +stdlib_complex128_t out = stdlib_base_cexp( z ); + +double re = stdlib_real( out ); +// returns 1.0 + +double im = stdlib_imag( out ); +// returns 0.0 +``` + +The function accepts the following arguments: + +- **z**: `[in] stdlib_complex128_t` input value. + +```c +stdlib_complex128_t stdlib_base_cexp( const stdlib_complex128_t z ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/cexp.h" +#include "stdlib/complex/float64.h" +#include "stdlib/complex/reim.h" +#include + +int main() { + const stdlib_complex128_t x[] = { + stdlib_complex128( 3.14, 1.5 ), + stdlib_complex128( -3.14, -1.5 ), + stdlib_complex128( 0.0, 0.0 ), + stdlib_complex128( 0.0/0.0, 0.0/0.0 ) + }; + + stdlib_complex128_t v; + stdlib_complex128_t y; + double re1; + double im1; + double re2; + double im2; + int i; + for ( i = 0; i < 4; i++ ) { + v = x[ i ]; + y = stdlib_base_cexp( v ); + stdlib_reim( v, &re1, &im1 ); + stdlib_reim( y, &re2, &im2 ); + printf( "cexp(%lf + %lfi) = %lf + %lfi\n", re1, im1, re2, im2 ); + } } ``` @@ -118,6 +220,10 @@ for ( i = 0; i < 100; i++ ) { +
+ + +