diff --git a/lib/node_modules/@stdlib/math/base/special/heavisidef/README.md b/lib/node_modules/@stdlib/math/base/special/heavisidef/README.md index df19a274c4f4..39d1c999b4d0 100644 --- a/lib/node_modules/@stdlib/math/base/special/heavisidef/README.md +++ b/lib/node_modules/@stdlib/math/base/special/heavisidef/README.md @@ -18,13 +18,13 @@ limitations under the License. --> -# Heaviside Function +# Heavisidef Function > Evaluate the [Heaviside function][heaviside-function] for a single-precision floating-point number.
-The [Heaviside function][heaviside-function] is defined as +The [Heavisidef function][heaviside-function] is defined as @@ -39,7 +39,7 @@ H(x) = \begin{cases} 1 & \textrm{if}\ x \gt 0 \\ 0 & \textrm{if}\ x \lt 0\end{ca -and is discontinuous at `0`. Depending on the context, the [Heaviside function][heaviside-function] may be defined as a continuous function. To define the [Heaviside function][heaviside-function] such that the function has rotational symmetry, +and is discontinuous at `0`. Depending on the context, the [Heavisidef function][heaviside-function] may be defined as a continuous function. To define the [Heavisidef function][heaviside-function] such that the function has rotational symmetry, @@ -54,7 +54,7 @@ H(x) = \begin{cases} x & \textrm{if}\ x \gt 0 \\ \frac{1}{2} & \textrm{if}\ x = -To define the [Heaviside function][heaviside-function] as a left-continuous function, +To define the [Heavisidef function][heaviside-function] as a left-continuous function, @@ -69,7 +69,7 @@ H(x) = \begin{cases} x & \textrm{if}\ x \gt 0 \\ 0 & \textrm{if}\ x \leq 0\end{c -To define the [Heaviside function][heaviside-function] as a right-continuous function, +To define the [Heavisidef function][heaviside-function] as a right-continuous function, @@ -164,6 +164,92 @@ logEachMap( 'H(%0.4f) = %0.4f', x, heavisidef ); + + +* * * + +
+ +## C APIs + + + +
+ +
+ + + + + +
+ +### Usage + +```c +#include "stdlib/math/base/special/heavisidef.h" +``` + +#### stdlib_base_heavisidef( x ) + +Evaluate the [Heavisidef function][heaviside-function]. + +```c +float out = stdlib_base_heavisidef( 0.0, 0 ); +// returns 0.0 + +out = stdlib_base_heavisidef( 3.141592653589793 / 2.0, 0 ); +// returns 1.0 +``` + +The function accepts the following arguments: + +- **x**: `[in] float` input value. +- **continuity**: `[in] int` input value. + +```c +float stdlib_base_heavisidef( const float x, int continuity ); +``` + +
+ + +
+
+ + +
+### Examples +```c +#include "stdlib/math/base/special/heavisidef.h" +#include +int main( void ) { + const float x[] = { 0.0, -0.523, 0.785, -1.047, 3.14 }; + float y; + int i; + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_heavisidef( x[ i ], STDLIB_HEAVISIDEF_CONTINUITY_HALF ); + printf( "heavisidef(%lf, half-maximum) = %lf\n", x[ i ], y ); + } + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_heavisidef( x[ i ], STDLIB_HEAVISIDEF_CONTINUITY_LEFT ); + printf( "heavisidef(%lf, left-continuous) = %lf\n", x[ i ], y ); + } + for ( i = 0; i < 5; i++ ) { + y = stdlib_base_heavisidef( x[ i ], STDLIB_HEAVISIDEF_CONTINUITY_RIGHT ); + printf( "heavisidef(%lf, right-continuous) = %lf\n", x[ i ], y ); + } +} +``` + +
+ + + +
+ + +