@stdlib/math-base-special-cphasef
v0.1.1
Published
Compute the argument of a single-precision complex floating-point number in radians.
Downloads
94
Readme
cphasef
Compute the argument of a single-precision complex floating-point number in radians.
The argument of a complex number, also known as the phase, is the angle of the radius extending from the origin to the complex number plotted in the complex plane and the positive real axis.
Installation
npm install @stdlib/math-base-special-cphasefUsage
var cphasef = require( '@stdlib/math-base-special-cphasef' );cphasef( z )
Computes the argument of a single-precision complex floating-point number.
var Complex64 = require( '@stdlib/complex-float32-ctor' );
var phi = cphasef( new Complex64( 5.0, 3.0 ) );
// returns ~0.5404Examples
var Complex64Array = require( '@stdlib/array-complex64' );
var uniform = require( '@stdlib/random-array-uniform' );
var logEachMap = require( '@stdlib/console-log-each-map' );
var cphasef = require( '@stdlib/math-base-special-cphasef' );
// Create an array of random numbers:
var arr = new Complex64Array( uniform( 200, -100.0, 100.0 ) );
// Compute the argument of each number in the array:
logEachMap( 'cphasef(%s) = %0.4f', arr, cphasef );C APIs
Usage
#include "stdlib/math/base/special/cphasef.h"stdlib_base_cphasef( z )
Computes the argument of a single-precision complex floating-point number.
#include "stdlib/complex/float32/ctor.h"
#include "stdlib/complex/float32/real.h"
#include "stdlib/complex/float32/imag.h"
stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f );
float out = stdlib_base_cphasef( z );
// returns ~0.5404fThe function accepts the following arguments:
- z:
[in] stdlib_complex64_tinput value.
float stdlib_base_cphasef( const stdlib_complex64_t z );Examples
#include "stdlib/math/base/special/cphasef.h"
#include "stdlib/complex/float32/ctor.h"
#include "stdlib/complex/float32/reim.h"
#include <stdio.h>
int main( void ) {
const stdlib_complex64_t x[] = {
stdlib_complex64( 3.14f, 1.0f ),
stdlib_complex64( -3.14f, -1.0f ),
stdlib_complex64( 0.0f, 0.0f ),
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
};
stdlib_complex64_t v;
float re;
float im;
float y;
int i;
for ( i = 0; i < 4; i++ ) {
v = x[ i ];
y = stdlib_base_cphasef( v );
stdlib_complex64_reim( v, &re, &im );
printf( "cphasef(%f + %fi) = %f\n", re, im, y );
}
}Notice
This package is part of stdlib, a standard library for JavaScript and Node.js, with an emphasis on numerical and scientific computing. The library provides a collection of robust, high performance libraries for mathematics, statistics, streams, utilities, and more.
For more information on the project, filing bug reports and feature requests, and guidance on how to develop stdlib, see the main project repository.
Community
License
See LICENSE.
Copyright
Copyright © 2016-2026. The Stdlib Authors.
