Skip to content

Commit dd5d9a0

Browse files
committed
Auto-generated commit
1 parent 6f06646 commit dd5d9a0

16 files changed

Lines changed: 687 additions & 69 deletions

File tree

CHANGELOG.md

Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3939,6 +3939,30 @@ This release closes the following issue:
39393939

39403940
<!-- /.package -->
39413941

3942+
<section class="package" id="math-base-special-cabs2f-unreleased">
3943+
3944+
#### [@stdlib/math/base/special/cabs2f](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cabs2f)
3945+
3946+
<details>
3947+
3948+
<section class="breaking-changes">
3949+
3950+
##### BREAKING CHANGES
3951+
3952+
- [`d89509f`](https://github.com/stdlib-js/stdlib/commit/d89509f17211915d1fd25c735efc40c2e54cc239): migrate to `stdlib_complex64_t`
3953+
3954+
- To migrate, users should update their usage of `complex` to `stdlib_complex64_t` which is available via `@stdlib/complex/float32/ctor` package.
3955+
3956+
</section>
3957+
3958+
<!-- /.breaking-changes -->
3959+
3960+
</details>
3961+
3962+
</section>
3963+
3964+
<!-- /.package -->
3965+
39423966
<section class="package" id="math-base-special-cabsf-unreleased">
39433967

39443968
#### [@stdlib/math/base/special/cabsf](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/math/base/special/cabsf)
@@ -7228,6 +7252,10 @@ This release closes the following issue:
72287252

72297253
### BREAKING CHANGES
72307254

7255+
- [`d89509f`](https://github.com/stdlib-js/stdlib/commit/d89509f17211915d1fd25c735efc40c2e54cc239): migrate to `stdlib_complex64_t`
7256+
7257+
- To migrate, users should update their usage of `complex` to `stdlib_complex64_t` which is available via `@stdlib/complex/float32/ctor` package.
7258+
72317259
- [`42aab9b`](https://github.com/stdlib-js/stdlib/commit/42aab9b7f3e2cb90710712f21c7e4d2b613b6a9d): use stdlib C complex64 dtype
72327260

72337261
- To migrate, users should provide a value having the type `stdlib_complex64_t`, rather than a built-in C99 single-precision complex dtype. This dtype is available via the package `@stdlib/complex/float32/ctor`.
@@ -9826,6 +9854,7 @@ A total of 30 people contributed to this release. Thank you to the following con
98269854

98279855
<details>
98289856

9857+
- [`d89509f`](https://github.com/stdlib-js/stdlib/commit/d89509f17211915d1fd25c735efc40c2e54cc239) - **refactor:** update `math/base/special/cabs2f` to follow latest project conventions [(#4767)](https://github.com/stdlib-js/stdlib/pull/4767) _(by Vivek Maurya, stdlib-bot, Karan Anand)_
98299858
- [`3656652`](https://github.com/stdlib-js/stdlib/commit/36566524e333dabea3b4b47c00b154accc1c2c23) - **feat:** add `math/base/special/lucasf` [(#6223)](https://github.com/stdlib-js/stdlib/pull/6223) _(by Harsh, stdlib-bot, Karan Anand)_
98309859
- [`dd317a4`](https://github.com/stdlib-js/stdlib/commit/dd317a4963fb9c35e1967a4b96556c3b060675c5) - **docs:** fix copy _(by Athan Reines)_
98319860
- [`e051a2f`](https://github.com/stdlib-js/stdlib/commit/e051a2fbf9cb31b562972c20c361a71b6ad837f6) - **fix:** improve type specificity _(by Athan Reines)_

base/special/cabs2f/README.md

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -139,18 +139,20 @@ for ( i = 0; i < 100; i++ ) {
139139
Computes the squared [absolute value][absolute-value] of a single-precision complex floating-point number.
140140

141141
```c
142-
#include <complex.h>
142+
#include "stdlib/complex/float32/ctor.h"
143143

144-
float y = stdlib_base_cabs2f( 5.0+3.0*I );
144+
stdlib_complex64_t z = stdlib_complex64( 5.0f, 3.0f );
145+
146+
float y = stdlib_base_cabs2f( z );
145147
// returns 34.0f
146148
```
147149

148150
The function accepts the following arguments:
149151

150-
- **z**: `[in] float complex` input value.
152+
- **z**: `[in] stdlib_complex64_t` input value.
151153

152154
```c
153-
float stdlib_base_cabs2f( const float complex z );
155+
float stdlib_base_cabs2f( const stdlib_complex64_t z );
154156
```
155157
156158
</section>
@@ -173,19 +175,28 @@ float stdlib_base_cabs2f( const float complex z );
173175
174176
```c
175177
#include "stdlib/math/base/special/cabs2f.h"
178+
#include "stdlib/complex/float32/ctor.h"
179+
#include "stdlib/complex/float32/reim.h"
176180
#include <stdio.h>
177-
#include <complex.h>
178181
179182
int main( void ) {
180-
const float complex x[] = { 3.14f+1.0f*I, -3.14f-1.0f*I, 0.0f+0.0f*I, 0.0f/0.0f+0.0f/0.0f*I };
181-
182-
float complex v;
183+
const stdlib_complex64_t x[] = {
184+
stdlib_complex64( 3.14f, 1.0f ),
185+
stdlib_complex64( -3.14f, -1.0f ),
186+
stdlib_complex64( 0.0f, 0.0f ),
187+
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
188+
};
189+
190+
stdlib_complex64_t v;
191+
float re;
192+
float im;
183193
float y;
184194
int i;
185195
for ( i = 0; i < 4; i++ ) {
186196
v = x[ i ];
187197
y = stdlib_base_cabs2f( v );
188-
printf( "f(%f + %f) = %f\n", crealf( v ), cimagf( v ), y );
198+
stdlib_complex64_reim( v, &re, &im );
199+
printf( "f(%f + %fi) = %f\n", re, im, y );
189200
}
190201
}
191202
```
Lines changed: 65 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,65 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2025 The Stdlib Authors.
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License");
7+
* you may not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS,
14+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*/
18+
19+
'use strict';
20+
21+
// MODULES //
22+
23+
var resolve = require( 'path' ).resolve;
24+
var bench = require( '@stdlib/bench' );
25+
var uniform = require( '@stdlib/random/base/uniform' );
26+
var isnanf = require( './../../../../base/assert/is-nanf' );
27+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
28+
var tryRequire = require( '@stdlib/utils/try-require' );
29+
var pkg = require( './../package.json' ).name;
30+
31+
32+
// VARIABLES //
33+
34+
var cabs2f = tryRequire( resolve( __dirname, './../lib/native.js' ) );
35+
var opts = {
36+
'skip': ( cabs2f instanceof Error )
37+
};
38+
39+
40+
// MAIN //
41+
42+
bench( pkg+'::native', opts, function benchmark( b ) {
43+
var values;
44+
var y;
45+
var i;
46+
47+
values = [
48+
new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ),
49+
new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) )
50+
];
51+
52+
b.tic();
53+
for ( i = 0; i < b.iterations; i++ ) {
54+
y = cabs2f( values[ i%values.length ] );
55+
if ( isnanf( y ) ) {
56+
b.fail( 'should not return NaN' );
57+
}
58+
}
59+
b.toc();
60+
if ( isnanf( y ) ) {
61+
b.fail( 'should not return NaN' );
62+
}
63+
b.pass( 'benchmark finished' );
64+
b.end();
65+
});

base/special/cabs2f/benchmark/c/native/benchmark.c

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,8 @@
1717
*/
1818

1919
#include "stdlib/math/base/special/cabs2f.h"
20-
#include <complex.h>
20+
#include "stdlib/complex/float32/ctor.h"
21+
#include "stdlib/complex/float32/reim.h"
2122
#include <stdlib.h>
2223
#include <stdio.h>
2324
#include <math.h>
@@ -91,20 +92,24 @@ static float rand_float( void ) {
9192
* @return elapsed time in seconds
9293
*/
9394
static double benchmark( void ) {
94-
float complex z;
9595
double elapsed;
9696
double t;
9797
float re;
9898
float im;
9999
float y;
100100
int i;
101101

102-
t = tic();
103-
for ( i = 0; i < ITERATIONS; i++ ) {
102+
stdlib_complex64_t z[ 100 ];
103+
104+
for ( i = 0; i < 100; i++ ) {
104105
re = ( 1000.0f*rand_float() ) - 500.0f;
105106
im = ( 1000.0f*rand_float() ) - 500.0f;
106-
z = re + im*I;
107-
y = stdlib_base_cabs2f( z );
107+
z[ i ] = stdlib_complex64( re, im );
108+
}
109+
110+
t = tic();
111+
for ( i = 0; i < ITERATIONS; i++ ) {
112+
y = stdlib_base_cabs2f( z[ i%100 ] );
108113
if ( y != y ) {
109114
printf( "should not return NaN\n" );
110115
break;

base/special/cabs2f/binding.gyp

Lines changed: 170 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,170 @@
1+
# @license Apache-2.0
2+
#
3+
# Copyright (c) 2025 The Stdlib Authors.
4+
#
5+
# Licensed under the Apache License, Version 2.0 (the "License");
6+
# you may not use this file except in compliance with the License.
7+
# You may obtain a copy of the License at
8+
#
9+
# http://www.apache.org/licenses/LICENSE-2.0
10+
#
11+
# Unless required by applicable law or agreed to in writing, software
12+
# distributed under the License is distributed on an "AS IS" BASIS,
13+
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
14+
# See the License for the specific language governing permissions and
15+
# limitations under the License.
16+
17+
# A `.gyp` file for building a Node.js native add-on.
18+
#
19+
# [1]: https://gyp.gsrc.io/docs/InputFormatReference.md
20+
# [2]: https://gyp.gsrc.io/docs/UserDocumentation.md
21+
{
22+
# List of files to include in this file:
23+
'includes': [
24+
'./include.gypi',
25+
],
26+
27+
# Define variables to be used throughout the configuration for all targets:
28+
'variables': {
29+
# Target name should match the add-on export name:
30+
'addon_target_name%': 'addon',
31+
32+
# Set variables based on the host OS:
33+
'conditions': [
34+
[
35+
'OS=="win"',
36+
{
37+
# Define the object file suffix:
38+
'obj': 'obj',
39+
},
40+
{
41+
# Define the object file suffix:
42+
'obj': 'o',
43+
}
44+
], # end condition (OS=="win")
45+
], # end conditions
46+
}, # end variables
47+
48+
# Define compile targets:
49+
'targets': [
50+
51+
# Target to generate an add-on:
52+
{
53+
# The target name should match the add-on export name:
54+
'target_name': '<(addon_target_name)',
55+
56+
# Define dependencies:
57+
'dependencies': [],
58+
59+
# Define directories which contain relevant include headers:
60+
'include_dirs': [
61+
# Local include directory:
62+
'<@(include_dirs)',
63+
],
64+
65+
# List of source files:
66+
'sources': [
67+
'<@(src_files)',
68+
],
69+
70+
# Settings which should be applied when a target's object files are used as linker input:
71+
'link_settings': {
72+
# Define libraries:
73+
'libraries': [
74+
'<@(libraries)',
75+
],
76+
77+
# Define library directories:
78+
'library_dirs': [
79+
'<@(library_dirs)',
80+
],
81+
},
82+
83+
# C/C++ compiler flags:
84+
'cflags': [
85+
# Enable commonly used warning options:
86+
'-Wall',
87+
88+
# Aggressive optimization:
89+
'-O3',
90+
],
91+
92+
# C specific compiler flags:
93+
'cflags_c': [
94+
# Specify the C standard to which a program is expected to conform:
95+
'-std=c99',
96+
],
97+
98+
# C++ specific compiler flags:
99+
'cflags_cpp': [
100+
# Specify the C++ standard to which a program is expected to conform:
101+
'-std=c++11',
102+
],
103+
104+
# Linker flags:
105+
'ldflags': [],
106+
107+
# Apply conditions based on the host OS:
108+
'conditions': [
109+
[
110+
'OS=="mac"',
111+
{
112+
# Linker flags:
113+
'ldflags': [
114+
'-undefined dynamic_lookup',
115+
'-Wl,-no-pie',
116+
'-Wl,-search_paths_first',
117+
],
118+
},
119+
], # end condition (OS=="mac")
120+
[
121+
'OS!="win"',
122+
{
123+
# C/C++ flags:
124+
'cflags': [
125+
# Generate platform-independent code:
126+
'-fPIC',
127+
],
128+
},
129+
], # end condition (OS!="win")
130+
], # end conditions
131+
}, # end target <(addon_target_name)
132+
133+
# Target to copy a generated add-on to a standard location:
134+
{
135+
'target_name': 'copy_addon',
136+
137+
# Declare that the output of this target is not linked:
138+
'type': 'none',
139+
140+
# Define dependencies:
141+
'dependencies': [
142+
# Require that the add-on be generated before building this target:
143+
'<(addon_target_name)',
144+
],
145+
146+
# Define a list of actions:
147+
'actions': [
148+
{
149+
'action_name': 'copy_addon',
150+
'message': 'Copying addon...',
151+
152+
# Explicitly list the inputs in the command-line invocation below:
153+
'inputs': [],
154+
155+
# Declare the expected outputs:
156+
'outputs': [
157+
'<(addon_output_dir)/<(addon_target_name).node',
158+
],
159+
160+
# Define the command-line invocation:
161+
'action': [
162+
'cp',
163+
'<(PRODUCT_DIR)/<(addon_target_name).node',
164+
'<(addon_output_dir)/<(addon_target_name).node',
165+
],
166+
},
167+
], # end actions
168+
}, # end target copy_addon
169+
], # end targets
170+
}

0 commit comments

Comments
 (0)