8000 Auto-generated commit · stdlib-js/complex@64fb074 · GitHub
[go: up one dir, main page]

Skip to content

Commit 64fb074

Browse files
committed
Auto-generated commit
1 parent f5f7028 commit 64fb074

31 files changed

+2471
-4
lines changed

CHANGELOG.md

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -134,6 +134,28 @@ This release closes the following issue:
134134

135135
<!-- /.package -->
136136

137+
<section class="package" id="complex-float32-base-sub-unreleased">
138+
139+
#### [@stdlib/complex/float32/base/sub](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float32/base/sub)
140+
141+
<details>
142+
143+
<section class="features">
144+
145+
##### Features
146+
147+
- [`3a62008`](https://github.com/stdlib-js/stdlib/commit/3a620083a7978286cc05db9231ecbee4d0478e1a) - add `complex/float32/base/sub`
148+
149+
</section>
150+
151+
<!-- /.features -->
152+
153+
</details>
154+
155+
</section>
156+
157+
<!-- /.package -->
158+
137159
<section class="package" id="complex-float64-base-unreleased">
138160

139161
#### [@stdlib/complex/float64/base](https://github.com/stdlib-js/stdlib/tree/develop/lib/node_modules/%40stdlib/complex/float64/base)
@@ -366,6 +388,8 @@ A total of 4 people contributed to this release. Thank you to the following cont
366388

367389
<details>
368390

391+
- [`89ecfe0`](https://github.com/stdlib-js/stdlib/commit/89ecfe0212aef0448017f8e404a3862fda851170) - **refactor:** update paths _(by Gururaj Gurram)_
392+
- [`3a62008`](https://github.com/stdlib-js/stdlib/commit/3a620083a7978286cc05db9231ecbee4d0478e1a) - **feat:** add `complex/float32/base/sub` _(by Gururaj Gurram)_
369393
- [`c7c1fb3`](https://github.com/stdlib-js/stdlib/commit/c7c1fb325f010a77313c58bfd51598af47720d89) - **refactor:** update paths _(by Gururaj Gurram)_
370394
- [`7e1f49e`](https://github.com/stdlib-js/stdlib/commit/7e1f49e881547d1212a1b411fb98b15ac0fb3fff) - **feat:** add `complex/float64/base/sub` _(by Gururaj Gurram)_
371395
- [`4866c10`](https://github.com/stdlib-js/stdlib/commit/4866c103418bc09e2c11a3f0238ac6941e830eca) - **feat:** add `complex/float32/base/neg` _(by Gururaj Gurram)_

float32/base/add/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -212,7 +212,7 @@ int main( void ) {
212212

213213
- <span class="package-name">[`@stdlib/complex/float64/base/add`][@stdlib/complex/float64/base/add]</span><span class="delimiter">: </span><span class="description">add two double-precision complex floating-point numbers.</span>
214214
- <span class="package-name">[`@stdlib/complex/float32/base/mul`][@stdlib/complex/float32/base/mul]</span><span class="delimiter">: </span><span class="description">multiply two single-precision complex floating-point numbers.</span>
215-
- <span class="package-name">[`@stdlib/math/base/ops/csubf`][@stdlib/math/base/ops/csubf]</span><span class="delimiter">: </span><span class="description">subtract two single-precision complex floating-point numbers.</span>
215+
- <span class="package-name">[`@stdlib/complex/float32/base/sub`][@stdlib/complex/float32/base/sub]</span><span class="delimiter">: </span><span class="description">subtract two single-precision complex floating-point numbers.</span>
216216

217217
</section>
218218

@@ -228,7 +228,7 @@ int main( void ) {
228228

229229
[@stdlib/complex/float32/base/mul]: https://github.com/stdlib-js/complex/tree/main/float32/base/mul
230230

231-
[@stdlib/math/base/ops/csubf]: https://github.com/stdlib-js/math-base-ops-csubf
231+
[@stdlib/complex/float32/base/sub]: https://github.com/stdlib-js/complex/tree/main/float32/base/sub
232232

233233
<!-- </related-links> -->
234234

float32/base/mul/README.md

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -269,7 +269,7 @@ int main( void ) {
269269

270270
- <span class="package-name">[`@stdlib/complex/float32/base/add`][@stdlib/complex/float32/base/add]</span><span class="delimiter">: </span><span class="description">add two single-precision complex floating-point numbers.</span>
271271
- <span class="package-name">[`@stdlib/complex/float64/base/mul`][@stdlib/complex/float64/base/mul]</span><span class="delimiter">: </span><span class="description">multiply two double-precision complex floating-point numbers.</span>
272-
- <span class="package-name">[`@stdlib/math/base/ops/csubf`][@stdlib/math/base/ops/csubf]</span><span class="delimiter">: </span><span class="description">subtract two single-precision complex floating-point numbers.</span>
272+
- <span class="package-name">[`@stdlib/complex/float32/base/sub`][@stdlib/complex/float32/base/sub]</span><span class="delimiter">: </span><span class="description">subtract two single-precision complex floating-point numbers.</span>
273273

274274
</section>
275275

@@ -285,7 +285,7 @@ int main( void ) {
285285

286286
[@stdlib/complex/float64/base/mul]: https://github.com/stdlib-js/complex/tree/main/float64/base/mul
287287

288-
[@stdlib/math/base/ops/csubf]: https://github.com/stdlib-js/math-base-ops-csubf
288+
[@stdlib/complex/float32/base/sub]: https://github.com/stdlib-js/complex/tree/main/float32/base/sub
289289

290290
<!-- </related-links> -->
291291

float32/base/sub/README.md

Lines changed: 239 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,239 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2021 The Stdlib Authors.
6+
7+
Licensed under the Apache License, Version 2.0 (the "License");
8+
you may not use this file except in compliance with the License.
9+
You may obtain a copy of the License at
10+
11+
http://www.apache.org/licenses/LICENSE-2.0
12+
13+
Unless required by applicable law or agreed to in writing, software
14+
distributed under the License is distributed on an "AS IS" BASIS,
15+
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
16+
See the License for the specific language governing permissions and
17+
limitations under the License.
18+
19+
-->
20+
21+
# csubf
22+
23+
> Subtract two single-precision complex floating-point numbers.
24+
25+
<section class="intro">
26+
27+
</section>
28+
29+
<!-- /.intro -->
30+
31+
<section class="usage">
32+
33+
## Usage
34+
35+
```javascript
36+
var csubf = require( '@stdlib/complex/float32/base/sub' );
37+
```
38+
39+
#### csubf( z1, z2 )
40+
41+
Subtracts two single-precision complex floating-point numbers.
42+
43+
```javascript
44+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
45+
var realf = require( '@stdlib/complex/float32/real' );
46+
var imagf = require( '@stdlib/complex/float32/imag' );
47+
48+
var z1 = new Complex64( 5.0, 3.0 );
49+
var z2 = new Complex64( -2.0, 1.0 );
50+
51+
var v = csubf( z1, z2 );
52+
// returns <Complex64>
53+
54+
var re = realf( v );
55+
// returns 7.0
56+
57+
var im = imagf( v );
58+
// returns 2.0
59+
```
60+
61+
</section>
62+
63+
<!-- /.usage -->
64+
65+
<section class="examples">
66+
67+
## Examples
68+
69+
<!-- eslint no-undef: "error" -->
70+
71+
```javascript
72+
var Complex64 = require( '@stdlib/complex/float32/ctor' );
73+
var discreteUniform = require( '@stdlib/random/base/discrete-uniform' ).factory;
74+
var csubf = require( '@stdlib/complex/float32/base/sub' );
75+
76+
var rand;
77+
var z1;
78+
var z2;
79+
var z3;
80+
var i;
81+
82+
rand = discreteUniform( -50, 50 );
83+
for ( i = 0; i < 100; i++ ) {
84+
z1 = new Complex64( rand(), rand() );
85+
z2 = new Complex64( rand(), rand() );
86+
z3 = csubf( z1, z2 );
87+
console.log( '(%s) - (%s) = %s', z1.toString(), z2.toString(), z3.toString() );
88+
}
89+
```
90+
91+
</section>
92+
93+
<!-- /.examples -->
94+
95+
<!-- C interface documentation. -->
96+
97+
* * *
98+
99+
<section class="c">
100+
101+
## C APIs
102+
103+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
104+
105+
<section class="intro">
106+
107+
</section>
108+
109+
<!-- /.intro -->
110+
111+
<!-- C usage documentation. -->
112+
113+
<section class="usage">
114+
115+
### Usage
116+
117+
```c
118+
#include "stdlib/complex/float32/base/sub.h"
119+
```
120+
121+
#### stdlib_base_complex64_sub( z1, z2 )
122+
123+
Subtracts two single-precision complex floating-point numbers.
124+
125+
```c
126+
#include "stdlib/complex/float32/ctor.h"
127+
#include "stdlib/complex/float32/real.h"
128+
#include "stdlib/complex/float32/imag.h"
129+
130+
stdlib_complex64_t z1 = stdlib_complex64( 5.0f, 3.0f );
131+
stdlib_complex64_t z2 = stdlib_complex64( -2.0f, 1.0f );
132+
stdlib_complex64_t out = stdlib_base_complex64_sub( z1, z2 );
133+
134+
float re = stdlib_complex64_real( out );
135+
// returns 7.0f
136+
137+
float im = stdlib_complex64_imag( out );
138+
// returns 2.0f
139+
```
140+
141+
The function accepts the following arguments:
142+
143+
- **z1**: `[in] stdlib_complex64_t` input value.
144+
- **z2**: `[in] stdlib_complex64_t` input value.
145+
146+
```c
147+
stdlib_complex64_t stdlib_base_complex64_sub( const stdlib_complex64_t z1, const stdlib_complex64_t z2 );
148+
```
149+
150+
</section>
151+
152+
<!-- /.usage -->
153+
154+
<!-- C API usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
155+
156+
<section class="notes">
157+
158+
</section>
159+
160+
<!-- /.notes -->
161+
162+
<!-- C API usage examples. -->
163+
164+
<section class="examples">
165+
166+
### Examples
167+
168+
```c
169+
#include "stdlib/complex/float32/base/sub.h"
170+
#include "stdlib/complex/float32/ctor.h"
171+
#include "stdlib/complex/float32/reim.h"
172+
#include <stdio.h>
173+
174+
int main( void ) {
175+
const stdlib_complex64_t x[] = {
176+
stdlib_complex64( 3.14f, 1.5f ),
177+
stdlib_complex64( -3.14f, 1.5f ),
178+
stdlib_complex64( 0.0f, -0.0f ),
179+
stdlib_complex64( 0.0f/0.0f, 0.0f/0.0f )
180+
};
181+
182+
stdlib_complex64_t v;
183+
stdlib_complex64_t y;
184+
float re;
185+
float im;
186+
int i;
187+
for ( i = 0; i < 4; i++ ) {
188+
v = x[ i ];
189+
stdlib_complex64_reim( v, &re, &im );
190+
printf( "z = %f + %fi\n", re, im );
191+
192+
y = stdlib_base_complex64_sub( v, v );
193+
stdlib_complex64_reim( y, &re, &im );
194+
printf( "csubf(z, z) = %f + %fi\n", re, im );
195+
}
196+
}
197+
```
198+
199+
</section>
200+
201+
<!-- /.examples -->
202+
203+
</section>
204+
205+
<!-- /.c -->
206+
207+
<!-- Section for related `stdlib` packages. Do not manually edit this section, as it is automatically populated. -->
208+
209+
<section class="related">
210+
211+
* * *
212+
213+
## See Also
214+
215+
- <span class="package-name">[`@stdlib/complex/float32/base/add`][@stdlib/complex/float32/base/add]</span><span class="delimiter">: </span><span class="description">add two single-precision complex floating-point numbers.</span>
216+
- <span class="package-name">[`@stdlib/complex/float32/base/mul`][@stdlib/complex/float32/base/mul]</span><span class="delimiter">: </span><span class="description">multiply two single-precision complex floating-point numbers.</span>
217+
- <span class="package-name">[`@stdlib/complex/float64/base/sub`][@stdlib/complex/float64/base/sub]</span><span class="delimiter">: </span><span class="description">subtract two double-precision complex floating-point numbers.</span>
218+
219+
</section>
220+
221+
<!-- /.related -->
222+
223+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
224+
225+
<section class="links">
226+
227+
<!-- <related-links> -->
228+
229+
[@stdlib/complex/float32/base/add]: https://github.com/stdlib-js/complex/tree/main/float32/base/add
230+
231+
[@stdlib/complex/float32/base/mul]: https://github.com/stdlib-js/complex/tree/main/float32/base/mul
232+
233+
[@stdlib/complex/float64/base/sub]: https://github.com/stdlib-js/complex/tree/main/float64/base/sub
234+
235+
<!-- </related-links> -->
236+
237+
</section>
238+
239+
<!-- /.links -->
Lines changed: 60 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,60 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2021 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 bench = require( '@stdlib/bench' );
24+
var uniform = require( '@stdlib/random/base/uniform' );
25+
var isnanf = require( '@stdlib/math/base/assert/is-nanf' );
26+
var Complex64 = require( './../../../../float32/ctor' );
27+
var realf = require( './../../../../float32/real' );
28+
var imagf = require( './../../../../float32/imag' );
29+
var pkg = require( './../package.json' ).name;
30+
var csubf = require( './../lib' );
31+
32+
33+
// MAIN //
34+
35+
bench( pkg, function benchmark( b ) {
36+
var values;
37+
var out;
38+
var z;
39+
var i;
40+
41+
values = [
42+
new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ),
43+
new Complex64( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) )
44+
];
45+
46+
b.tic();
47+
for ( i = 0; i < b.iterations; i++ ) {
48+
z = values[ i%values.length ];
49+
out = csubf( z, z );
50+
if ( typeof out !== 'object' ) {
51+
b.fail( 'should return an object' );
52+
}
53+
}
54+
b.toc();
55+
if ( isnanf( realf( out ) ) || isnanf( imagf( out ) ) ) {
56+
b.fail( 'should not return NaN' );
57+
}
58+
b.pass( 'benchmark finished' );
59+
b.end();
60+
});

0 commit comments

Comments
 (0)
0