Identity Function

Evaluate the identity function of a double-precision complex floating-point number.

The identity-function is defined as

f left-parenthesis z right-parenthesis equals z

for all z.

Usage

var cidentity = require( '@stdlib/math/base/special/cidentity' );

cidentity( z )

Evaluates the identity function for a double-precision complex floating-point number.

var Complex128 = require( '@stdlib/complex/float64' );
var real = require( '@stdlib/complex/real' );
var imag = require( '@stdlib/complex/imag' );

var v = cidentity( new Complex128( -1.0, 2.0 ) );
// returns <Complex128>

var re = real( v );
// returns -1.0

var im = imag( v );
// returns 2.0

Examples

var discreteUniform = require( '@stdlib/random/base/discrete-uniform' );
var Complex128 = require( '@stdlib/complex/float64' );
var cidentity = require( '@stdlib/math/base/special/cidentity' );

var z;
var i;
for ( i = 0; i < 100; i++ ) {
    z = new Complex128( discreteUniform( -50, 50 ), discreteUniform( -50, 50 ) );
    console.log( 'identity(%s) = %s', z, cidentity( z ) );
}

C APIs

Usage

#include "stdlib/math/base/special/cidentity.h"

stdlib_base_cidentity( z )

Evaluates the identity function for a double-precision complex floating-point number.

#include <complex.h>

double complex y = stdlib_base_cidentity( 2.0+2.0*I );
// returns 2.0+2.0*I

The function accepts the following arguments:

  • z: [in] double complex input value.
double complex stdlib_base_cidentity( const double complex z );

Examples

#include "stdlib/math/base/special/cidentity.h"
#include <stdio.h>
#include <complex.h>

int main() {
    double complex x[] = { 3.14+1.0*I, -3.14-1.0*I, 0.0+0.0*I, 0.0/0.0+0.0/0.0*I };

    double complex v;
    double complex y;
    int i;
    for ( i = 0; i < 4; i++ ) {
        v = x[ i ];
        y = stdlib_base_cidentity( v );
        printf( "f(%lf + %lf) = %lf + %lf\n", creal( v ), cimag( v ), creal( y ), cimag( y ) );
    }
}
Did you find this page helpful?