Skip to content

Commit 1a93d8f

Browse files
committed
feat: add complex/float64/base/assert/is-not-equal
Ref: #2260
1 parent 33db937 commit 1a93d8f

File tree

15 files changed

+1098
-0
lines changed

15 files changed

+1098
-0
lines changed
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,221 @@
1+
<!--
2+
3+
@license Apache-2.0
4+
5+
Copyright (c) 2024 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+
# isNotEqual
22+
23+
> Test whether two double-precision complex floating-point numbers are not equal.
24+
25+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
26+
27+
<section class="intro">
28+
29+
</section>
30+
31+
<!-- /.intro -->
32+
33+
<!-- Package usage documentation. -->
34+
35+
<section class="usage">
36+
37+
## Usage
38+
39+
```javascript
40+
var isNotEqual = require( '@stdlib/complex/float64/base/assert/is-not-equal' );
41+
```
42+
43+
#### isNotEqual( z1, z2 )
44+
45+
Tests whether two double-precision complex floating-point numbers are not equal.
46+
47+
```javascript
48+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
49+
50+
var z1 = new Complex128( 5.0, 3.0 );
51+
var z2 = new Complex128( 5.0, -3.0 );
52+
53+
var out = isNotEqual( z1, z2 );
54+
// returns true
55+
```
56+
57+
</section>
58+
59+
<!-- /.usage -->
60+
61+
<!-- Package usage notes. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
62+
63+
<section class="notes">
64+
65+
</section>
66+
67+
<!-- /.notes -->
68+
69+
<!-- Package usage examples. -->
70+
71+
<section class="examples">
72+
73+
## Examples
74+
75+
<!-- eslint no-undef: "error" -->
76+
77+
```javascript
78+
var Complex128 = require( '@stdlib/complex/float64/ctor' );
79+
var isNotEqual = require( '@stdlib/complex/float64/base/assert/is-not-equal' );
80+
81+
var z1 = new Complex128( 5.0, 3.0 );
82+
var z2 = new Complex128( 5.0, 3.0 );
83+
var out = isNotEqual( z1, z2 );
84+
// returns false
85+
86+
z1 = new Complex128( -5.0, -3.0 );
87+
z2 = new Complex128( 5.0, 3.0 );
88+
out = isNotEqual( z1, z2 );
89+
// returns true
90+
91+
z1 = new Complex128( NaN, 3.0 );
92+
z2 = new Complex128( NaN, 3.0 );
93+
out = isNotEqual( z1, z2 );
94+
// returns true
95+
```
96+
97+
</section>
98+
99+
<!-- /.examples -->
100+
101+
<!-- C interface documentation. -->
102+
103+
* * *
104+
105+
<section class="c">
106+
107+
## C APIs
108+
109+
<!-- Section to include introductory text. Make sure to keep an empty line after the intro `section` element and another before the `/section` close. -->
110+
111+
<section class="intro">
112+
113+
</section>
114+
115+
<!-- /.intro -->
116+
117+
<!-- C usage documentation. -->
118+
119+
<section class="usage">
120+
121+
### Usage
122+
123+
```c
124+
#include "stdlib/complex/float64/base/assert/is_not_equal.h"
125+
```
126+
127+
#### stdlib_base_complex128_is_not_equal( z1, z2 )
128+
129+
Tests whether double-precision complex floating-point numbers are not equal.
130+
131+
```c
132+
#include "stdlib/complex/float64/ctor.h"
133+
#include <stdbool.h>
134+
135+
stdlib_complex128_t z1 = stdlib_complex128( 5.0, 2.0 );
136+
stdlib_complex128_t z2 = stdlib_complex128( 5.0, -2.0 );
137+
138+
bool v = stdlib_base_complex128_is_not_equal( z1, z2 );
139+
```
140+
141+
The function accepts the following arguments:
142+
143+
- **z1**: `[in] stdlib_complex128_t` first double-precision complex floating-point number.
144+
- **z2**: `[in] stdlib_complex128_t` second double-precision complex floating-point number.
145+
146+
```c
147+
bool stdlib_base_complex128_is_not_equal( const stdlib_complex128_t z1, const stdlib_complex128_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/float64/base/assert/is_not_equal.h"
170+
#include "stdlib/complex/float64/ctor.h"
171+
#include <stdbool.h>
172+
#include <stdio.h>
173+
174+
int main( void ) {
175+
const stdlib_complex128_t z[] = {
176+
stdlib_complex128( 5.0, 2.0 ),
177+
stdlib_complex128( -2.0, 1.0 ),
178+
stdlib_complex128( 0.0, -0.0 ),
179+
stdlib_complex128( 0.0/0.0, 0.0/0.0 )
180+
};
181+
182+
bool v;
183+
int i;
184+
for ( i = 0; i < 4; i++ ) {
185+
v = stdlib_base_complex128_is_not_equal( z[ i ], z[ i ] );
186+
printf( "Equal? %s\n", ( v ) ? "True" : "False" );
187+
}
188+
}
189+
```
190+
191+
</section>
192+
193+
<!-- /.examples -->
194+
195+
</section>
196+
197+
<!-- /.c -->
198+
199+
<!-- Section to include cited references. If references are included, add a horizontal rule *before* the section. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
200+
201+
<section class="references">
202+
203+
</section>
204+
205+
<!-- /.references -->
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+
</section>
212+
213+
<!-- /.related -->
214+
215+
<!-- Section for all links. Make sure to keep an empty line after the `section` element and another before the `/section` close. -->
216+
217+
<section class="links">
218+
219+
</section>
220+
221+
<!-- /.links -->
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,63 @@
1+
/**
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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 Complex128 = require( '@stdlib/complex/float64/ctor' );
25+
var randu = require( '@stdlib/random/base/randu' );
26+
var isBoolean = require( '@stdlib/assert/is-boolean' ).isPrimitive;
27+
var pkg = require( './../package.json' ).name;
28+
var isNotEqual = require( './../lib' );
29+
30+
31+
// MAIN //
32+
33+
bench( pkg, function benchmark( b ) {
34+
var z1;
35+
var z2;
36+
var v;
37+
var i;
38+
39+
z1 = [
40+
new Complex128( randu(), randu() ),
41+
new Complex128( randu(), randu() )
42+
];
43+
z2 = [
44+
new Complex128( randu(), randu() ),
45+
new Complex128( randu(), randu() ),
46+
z1[ 0 ],
47+
z1[ 1 ]
48+
];
49+
50+
b.tic();
51+
for ( i = 0; i < b.iterations; i++ ) {
52+
v = isNotEqual( z1[ i%z1.length ], z2[ i%z2.length ] );
53+
if ( typeof v !== 'boolean' ) {
54+
b.fail( 'should return a boolean' );
55+
}
56+
}
57+
b.toc();
58+
if ( !isBoolean( v ) ) {
59+
b.fail( 'should return a boolean' );
60+
}
61+
b.pass( 'benchmark finished' );
62+
b.end();
63+
});
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
2+
{{alias}}( z1, z2 )
3+
Tests whether two double-precision complex floating-point numbers are not
4+
equal.
5+
6+
Parameters
7+
----------
8+
z1: Complex128
9+
First complex number.
10+
11+
z2: Complex128
12+
Second complex number.
13+
14+
Returns
15+
-------
16+
out: boolean
17+
Result.
18+
19+
Examples
20+
--------
21+
> var z1 = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, 3.0 );
22+
> var z2 = new {{alias:@stdlib/complex/float64/ctor}}( 5.0, -3.0 );
23+
> var v = {{alias}}( z1, z2 )
24+
true
25+
26+
See Also
27+
--------
28+
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
/*
2+
* @license Apache-2.0
3+
*
4+
* Copyright (c) 2024 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+
// TypeScript Version: 4.1
20+
21+
import Complex128 = require( '@stdlib/complex/float64/ctor' );
22+
23+
/**
24+
* Tests whether two double-precision complex floating-point numbers are not equal.
25+
*
26+
* @param z1 - first complex number
27+
* @param z2 - second complex number
28+
* @returns boolean indicating if both complex numbers are not equal
29+
*
30+
* @example
31+
* var Complex128 = require( '@stdlib/complex/float64/ctor' );
32+
*
33+
* var z1 = new Complex128( 5.0, 3.0 );
34+
* var z2 = new Complex128( 5.0, -3.0 );
35+
*
36+
* var v = isNotEqual( z1, z2 );
37+
* // returns true
38+
*/
39+
declare function isNotEqual( z1: Complex128, z2: Complex128 ): boolean;
40+
41+
42+
// EXPORTS //
43+
44+
export = isNotEqual;

0 commit comments

Comments
 (0)