conj
Return the complex conjugate of a double-precision complex floating-point number.
Usage
var conj = require( '@stdlib/complex/conj' );
conj( z )
Returns the complex conjugate of a double-precision complex floating-point number.
var Complex128 = require( '@stdlib/complex/float64' );
var z = new Complex128( 5.0, 3.0 );
var str = z.toString();
// returns '5 + 3i'
var v = conj( z );
str = v.toString();
// returns '5 - 3i'
Examples
var Complex128 = require( '@stdlib/complex/float64' );
var randu = require( '@stdlib/random/base/randu' );
var round = require( '@stdlib/math/base/special/round' );
var conj = require( '@stdlib/complex/conj' );
var re;
var im;
var z;
var i;
for ( i = 0; i < 100; i++ ) {
re = round( (randu()*100.0) - 50.0 );
im = round( (randu()*50.0) - 25.0 );
z = new Complex128( re, im );
console.log( 'conj(%s) = %s', z.toString(), conj( z ).toString() );
}
C APIs
Usage
#include "stdlib/complex/conj.h"
stdlib_conj( z )
Returns the complex conjugate of a double-precision complex floating-point number.
#include "stdlib/complex/float64.h"
#include "stdlib/complex/real.h"
#include "stdlib/complex/imag.h"
stdlib_complex128_t z = stdlib_complex128( 5.0, 2.0 );
// ...
stdlib_complex128_t v = stdlib_conj( z );
double re = stdlib_real( v );
// returns 5.0
double im = stdlib_imag( v );
// returns -2.0
The function accepts the following arguments:
- z:
[in] stdlib_complex128_t
double-precision complex floating-point number.
stdlib_complex128_t stdlib_conj( const stdlib_complex128_t z );
Examples
#include "stdlib/complex/conj.h"
#include "stdlib/complex/real.h"
#include "stdlib/complex/imag.h"
#include "stdlib/complex/float64.h"
#include <stdio.h>
int main() {
stdlib_complex128_t x[] = {
stdlib_complex128( 5.0, 2.0 ),
stdlib_complex128( -2.0, 1.0 ),
stdlib_complex128( 0.0, -0.0 ),
stdlib_complex128( 0.0/0.0, 0.0/0.0 )
};
stdlib_complex128_t z;
stdlib_complex128_t v;
int i;
for ( i = 0; i < 4; i++ ) {
z = x[ i ];
v = stdlib_conj( z );
printf( "conj(%lf + %lfi) = %lf + %lfi\n", stdlib_real( z ), stdlib_imag( z ), stdlib_real( v ), stdlib_imag( v ) );
}
}