Skip to content

Commit 53c811f

Browse files
committed
feat: add math/base/special/cpolarf
1 parent 2c58cce commit 53c811f

File tree

25 files changed

+132
-233
lines changed

25 files changed

+132
-233
lines changed

lib/node_modules/@stdlib/math/base/special/cpolarf/README.md

Lines changed: 23 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
33
@license Apache-2.0
44
5-
Copyright (c) 2018 The Stdlib Authors.
5+
Copyright (c) 2025 The Stdlib Authors.
66
77
Licensed under the Apache License, Version 2.0 (the "License");
88
you may not use this file except in compliance with the License.
@@ -77,9 +77,7 @@ var bool = ( v === out );
7777
```javascript
7878
var Complex64 = require( '@stdlib/complex/float32/ctor' );
7979
var randu = require( '@stdlib/random/base/randu' );
80-
var round = require( '@stdlib/math/base/special/round' );
81-
var real = require( '@stdlib/complex/float32/real' );
82-
var imag = require( '@stdlib/complex/float32/imag' );
80+
var roundf = require( '@stdlib/math/base/special/roundf' );
8381
var cpolarf = require( '@stdlib/math/base/special/cpolarf' );
8482

8583
var re;
@@ -89,12 +87,12 @@ var o;
8987
var i;
9088

9189
for ( i = 0; i < 100; i++ ) {
92-
re = round( randu()*100.0 ) - 50.0;
93-
im = round( randu()*100.0 ) - 50.0;
90+
re = roundf( randu()*100.0 ) - 50.0;
91+
im = roundf( randu()*100.0 ) - 50.0;
9492
z = new Complex64( re, im );
9593
o = cpolarf( z );
9694
z = z.toString();
97-
console.log( 'abs(%s) = %d. arg(%s) = %d', z, o[0], z, o[1] );
95+
console.log( 'absf(%s) = %d. argf(%s) = %d', z, o[0], z, o[1] );
9896
}
9997
```
10098

@@ -137,20 +135,20 @@ Computes the [absolute value][@stdlib/math/base/special/cabsf] and [phase][@stdl
137135
#include "stdlib/complex/float32/real.h"
138136
#include "stdlib/complex/float32/imag.h"
139137

140-
stdlib_complex128_t z = stdlib_complex128( 5.0, 3.0 );
141-
double cabsf;
142-
double cphasef;
138+
stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f );
139+
float cabsf;
140+
float cphasef;
143141
stdlib_base_cpolarf( z, &cabsf, &cphasef );
144142
```
145143
146144
The function accepts the following arguments:
147145
148-
- **z**: `[in] stdlib_complex128_t` input value.
149-
- **cabsf**: `[out] double*` destination for the absolute value.
150-
- **cphasef**: `[out] double*` destination for the phase value in radians.
146+
- **z**: `[in] stdlib_complex64_t` input value.
147+
- **cabsf**: `[out] float*` destination for the absolute value.
148+
- **cphasef**: `[out] float*` destination for the phase value in radians.
151149
152150
```c
153-
double stdlib_base_cpolarf( const stdlib_complex128_t z, double *cabsf, double *cphasef );
151+
float stdlib_base_cpolarf( const stdlib_complex64_t z, float *cabsf, float *cphasef );
154152
```
155153

156154
</section>
@@ -178,22 +176,22 @@ double stdlib_base_cpolarf( const stdlib_complex128_t z, double *cabsf, double *
178176
#include <stdio.h>
179177

180178
int main( void ) {
181-
const stdlib_complex128_t x[] = {
182-
stdlib_complex128( 3.14, 1.0 ),
183-
stdlib_complex128( -3.14, -1.0 ),
184-
stdlib_complex128( 0.0, 0.0 ),
185-
stdlib_complex128( 0.0/0.0, 0.0/0.0 )
179+
const stdlib_complex64_t x[] = {
180+
stdlib_complex64( 3.14f, 1.0f ),
181+
stdlib_complex64( -3.14f, -1.0f ),
182+
stdlib_complex64( 0.0f, 0.0f ),
183+
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
186184
};
187185

188-
double cphasef;
189-
double cabsf;
190-
double re;
191-
double im;
186+
float cphasef;
187+
float cabsf;
188+
float re;
189+
float im;
192190
int i;
193191
for ( i = 0; i < 4; i++ ) {
194192
stdlib_base_cpolarf( x[i], &cabsf, &cphasef );
195-
stdlib_complex128_reim( x[i], &re, &im );
196-
printf( "cpolarf(%lf + %lfi) => cabsf: %lf, cphasef: %lf\n", re, im, cabsf, cphasef );
193+
stdlib_complex64_reim( x[i], &re, &im );
194+
printf( "cpolarf(%f + %fi) => cabsf: %f, cphasef: %f\n", re, im, cabsf, cphasef );
197195
}
198196
}
199197
```
@@ -210,13 +208,6 @@ int main( void ) {
210208
211209
<section class="related">
212210
213-
* * *
214-
215-
## See Also
216-
217-
- <span class="package-name">[`@stdlib/math/base/special/cabsf`][@stdlib/math/base/special/cabsf]</span><span class="delimiter">: </span><span class="description">compute the absolute value of a single-precision complex floating-point number.</span>
218-
- <span class="package-name">[`@stdlib/math/base/special/cphasef`][@stdlib/math/base/special/cphasef]</span><span class="delimiter">: </span><span class="description">compute the argument of a single-precision complex floating-point number in radians.</span>
219-
220211
</section>
221212
222213
<!-- /.related -->

lib/node_modules/@stdlib/math/base/special/cpolarf/benchmark/benchmark.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2018 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/benchmark/benchmark.native.js

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -23,7 +23,7 @@
2323
var resolve = require( 'path' ).resolve;
2424
var bench = require( '@stdlib/bench' );
2525
var uniform = require( '@stdlib/random/base/uniform' );
26-
var isArray = require( '@stdlib/assert/is-array' );
26+
var isFloat32Array = require( '@stdlib/assert/is-float32array' );
2727
var Complex64 = require( '@stdlib/complex/float32/ctor' );
2828
var tryRequire = require( '@stdlib/utils/try-require' );
2929
var pkg = require( './../package.json' ).name;
@@ -57,8 +57,8 @@ bench( pkg+'::native', opts, function benchmark( b ) {
5757
}
5858
}
5959
b.toc();
60-
if ( !isArray( y ) ) {
61-
b.fail( 'should return an array' );
60+
if ( !isFloat32Array( y ) ) {
61+
b.fail( 'should return a Float32Array' );
6262
}
6363
b.pass( 'benchmark finished' );
6464
b.end();

lib/node_modules/@stdlib/math/base/special/cpolarf/benchmark/c/native/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2023 The Stdlib Authors.
4+
# Copyright (c) 2025 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/benchmark/c/native/benchmark.c

Lines changed: 14 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/**
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2023 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.
@@ -81,9 +81,9 @@ static double tic( void ) {
8181
*
8282
* @return random number
8383
*/
84-
static double rand_double( void ) {
84+
static float rand_float( void ) {
8585
int r = rand();
86-
return (double)r / ( (double)RAND_MAX + 1.0 );
86+
return (float)r / ( (float)RAND_MAX + 1.0f );
8787
}
8888

8989
/**
@@ -93,21 +93,23 @@ static double rand_double( void ) {
9393
*/
9494
static double benchmark( void ) {
9595
double elapsed;
96-
double cphasef;
97-
double cabsf;
98-
double re;
99-
double im;
96+
float cphasef;
97+
float cabsf;
98+
float re;
99+
float im;
100100
double t;
101101
int i;
102102

103-
stdlib_complex128_t z;
103+
stdlib_complex64_t z[ 100 ];
104+
for ( i = 0; i < 100; i++ ) {
105+
re = ( 1000.0f*rand_float() ) - 500.0f;
106+
im = ( 1000.0f*rand_float() ) - 500.0f;
107+
z[ i ] = stdlib_complex64( re, im );
108+
}
104109

105110
t = tic();
106111
for ( i = 0; i < ITERATIONS; i++ ) {
107-
re = ( 1000.0*rand_double() ) - 500.0;
108-
im = ( 1000.0*rand_double() ) - 500.0;
109-
z = stdlib_complex128( re, im );
110-
stdlib_base_cpolarf( z, &cabsf, &cphasef);
112+
stdlib_base_cpolarf( z[ i%100 ], &cabsf, &cphasef);
111113
if ( cabsf != cabsf ) {
112114
printf( "should not return NaN\n" );
113115
break;

lib/node_modules/@stdlib/math/base/special/cpolarf/binding.gyp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
# @license Apache-2.0
22
#
3-
# Copyright (c) 2023 The Stdlib Authors.
3+
# Copyright (c) 2025 The Stdlib Authors.
44
#
55
# Licensed under the Apache License, Version 2.0 (the "License");
66
# you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/docs/types/index.d.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/docs/types/test.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
/*
22
* @license Apache-2.0
33
*
4-
* Copyright (c) 2019 The Stdlib Authors.
4+
* Copyright (c) 2025 The Stdlib Authors.
55
*
66
* Licensed under the Apache License, Version 2.0 (the "License");
77
* you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/examples/c/Makefile

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#/
22
# @license Apache-2.0
33
#
4-
# Copyright (c) 2023 The Stdlib Authors.
4+
# Copyright (c) 2025 The Stdlib Authors.
55
#
66
# Licensed under the Apache License, Version 2.0 (the "License");
77
# you may not use this file except in compliance with the License.

lib/node_modules/@stdlib/math/base/special/cpolarf/examples/c/example.c

Lines changed: 12 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
/**
33
* @license Apache-2.0
44
*
5-
* Copyright (c) 2023 The Stdlib Authors.
5+
* Copyright (c) 2025 The Stdlib Authors.
66
*
77
* Licensed under the Apache License, Version 2.0 (the "License");
88
* you may not use this file except in compliance with the License.
@@ -23,21 +23,21 @@
2323
#include <stdio.h>
2424

2525
int main( void ) {
26-
const stdlib_complex128_t x[] = {
27-
stdlib_complex128( 3.14, 1.0 ),
28-
stdlib_complex128( -3.14, -1.0 ),
29-
stdlib_complex128( 0.0, 0.0 ),
30-
stdlib_complex128( 0.0/0.0, 0.0/0.0 )
26+
const stdlib_complex64_t x[] = {
27+
stdlib_complex64( 3.14f, 1.0f ),
28+
stdlib_complex64( -3.14f, -1.0f ),
29+
stdlib_complex64( 0.0f, 0.0f ),
30+
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
3131
};
3232

33-
double cphasef;
34-
double cabsf;
35-
double re;
36-
double im;
33+
float cphasef;
34+
float cabsf;
35+
float re;
36+
float im;
3737
int i;
3838
for ( i = 0; i < 4; i++ ) {
3939
stdlib_base_cpolarf( x[i], &cabsf, &cphasef );
40-
stdlib_complex128_reim( x[i], &re, &im );
41-
printf( "cpolarf(%lf + %lfi) => cabsf: %lf, cphasef: %lf\n", re, im, cabsf, cphasef );
40+
stdlib_complex64_reim( x[i], &re, &im );
41+
printf( "cpolarf(%f + %fi) => cabsf: %f, cphasef: %f\n", re, im, cabsf, cphasef );
4242
}
4343
}

0 commit comments

Comments
 (0)