diff --git a/lib/node_modules/@stdlib/math/base/special/cfloor/README.md b/lib/node_modules/@stdlib/math/base/special/cfloor/README.md index 1d0d22e2331c..1a4ba9c052b1 100644 --- a/lib/node_modules/@stdlib/math/base/special/cfloor/README.md +++ b/lib/node_modules/@stdlib/math/base/special/cfloor/README.md @@ -20,7 +20,7 @@ limitations under the License. # Floor -> Round a complex number toward negative infinity. +> Round a double-precision complex floating-point number toward negative infinity.
@@ -30,36 +30,50 @@ limitations under the License. var cfloor = require( '@stdlib/math/base/special/cfloor' ); ``` -#### cfloor( \[out,] re, im ) +#### cfloor( z ) -Rounds a `complex` number comprised of a **real** component `re` and an **imaginary** component `im` toward negative infinity. +Rounds a double-precision complex floating-point number toward negative infinity. ```javascript -var v = cfloor( -4.2, 5.5 ); -// returns [ -5.0, 5.0 ] +var Complex128 = require( '@stdlib/complex/float64' ); +var real = require( '@stdlib/complex/real' ); +var imag = require( '@stdlib/complex/imag' ); -v = cfloor( 9.99999, 0.1 ); -// returns [ 9.0, 0.0 ] +var v = cfloor( new Complex128( -4.2, 5.5 ) ); +// returns -v = cfloor( 0.0, 0.0 ); -// returns [ 0.0, 0.0 ] +var re = real( v ); +// returns -5.0 -v = cfloor( NaN, NaN ); -// returns [ NaN, NaN ] -``` +var im = imag( v ); +// returns 5.0 -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. +v = cfloor( new Complex128( 9.99999, 0.1 ) ); +// returns -```javascript -var Float32Array = require( '@stdlib/array/float32' ); +re = real( v ); +// returns 9.0 + +im = imag( v ); +// returns 0.0 + +v = cfloor( new Complex128( 0.0, 0.0 ) ); +// returns + +re = real( v ); +// returns 0.0 -var out = new Float32Array( 2 ); +im = imag( v ); +// returns 0.0 -var v = cfloor( out, -4.2, 5.5 ); -// returns [ -5.0, 5.0 ] +v = cfloor( new Complex128( NaN, NaN ) ); +// returns -var bool = ( v === out ); -// returns true +re = real( v ); +// returns NaN + +im = imag( v ); +// returns NaN ```
@@ -75,14 +89,11 @@ var bool = ( v === out ); ```javascript var Complex128 = require( '@stdlib/complex/float64' ); var randu = require( '@stdlib/random/base/randu' ); -var real = require( '@stdlib/complex/real' ); -var imag = require( '@stdlib/complex/imag' ); var cfloor = require( '@stdlib/math/base/special/cfloor' ); var re; var im; var z; -var o; var w; var i; @@ -90,8 +101,7 @@ for ( i = 0; i < 100; i++ ) { re = ( randu()*100.0 ) - 50.0; im = ( randu()*100.0 ) - 50.0; z = new Complex128( re, im ); - o = cfloor( real(z), imag(z) ); - w = new Complex128( o[ 0 ], o[ 1 ] ); + w = cfloor( z ); console.log( 'floor(%s) = %s', z.toString(), w.toString() ); } ``` @@ -100,6 +110,117 @@ for ( i = 0; i < 100; i++ ) { + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/cfloor.h" +``` + +#### stdlib_base_cfloor( z ) + +Rounds a double-precision complex floating-point number toward negative infinity. + +```c +#include "stdlib/complex/float64.h" +#include "stdlib/complex/real.h" +#include "stdlib/complex/imag.h" + +stdlib_complex128_t z = stdlib_complex128( 2.5, -1.5 ); + +stdlib_complex128_t out = stdlib_base_cfloor( z ); + +double re = stdlib_real( out ); +// returns 2.0 + +double im = stdlib_imag( out ); +// returns -2.0 +``` + +The function accepts the following arguments: + +- **z**: `[in] stdlib_complex128_t` input value. + +```c +stdlib_complex128_t stdlib_base_cfloor( const stdlib_complex128_t z ); +``` + +
+ + + + + +
+ +
+ + + + + +
+ +### Examples + +```c +#include "stdlib/math/base/special/cfloor.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_cfloor( v ); + stdlib_reim( v, &re1, &im1 ); + stdlib_reim( y, &re2, &im2 ); + printf( "cfloor(%lf + %lfi) = %lf + %lfi\n", re1, im1, re2, im2 ); + } +} +``` + +
+ + + +
+ + +