-
-
Notifications
You must be signed in to change notification settings - Fork 837
feat: add assign and strided methods to csignumf #7331
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Changes from all commits
165c4a2
3916b0e
f42f40d
418d3f9
acc04d2
2e59850
eac64a6
4b3c2bf
bfd26de
bd6f38c
28f9780
0b1a520
10a506a
f06e5e0
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,69 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2025 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var uniform = require( '@stdlib/random/array/uniform' ); | ||
var isnanf = require( '@stdlib/math/base/assert/is-nanf' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var pkg = require( './../package.json' ).name; | ||
var csignumf = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var options = { | ||
'dtype': 'float32' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+':assign', function benchmark( b ) { | ||
var out; | ||
var re; | ||
var im; | ||
var N; | ||
var i; | ||
var j; | ||
|
||
N = 100; | ||
re = uniform( N, -500.0, 500.0, options ); | ||
im = uniform( N, -500.0, 500.0, options ); | ||
|
||
out = new Float32Array( 2 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
j = i % N; | ||
out = csignumf.assign( re[ j ], im[ j ], out, 1, 0 ); | ||
if ( typeof out !== 'object' ) { | ||
b.fail( 'should return an object' ); | ||
} | ||
} | ||
b.toc(); | ||
|
||
if ( isnanf( out[ 0 ] ) || isnanf( out[ 1 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/** | ||
* @license Apache-2.0 | ||
* | ||
* Copyright (c) 2025 The Stdlib Authors. | ||
* | ||
* Licensed under the Apache License, Version 2.0 (the "License"); | ||
* you may not use this file except in compliance with the License. | ||
* You may obtain a copy of the License at | ||
* | ||
* http://www.apache.org/licenses/LICENSE-2.0 | ||
* | ||
* Unless required by applicable law or agreed to in writing, software | ||
* distributed under the License is distributed on an "AS IS" BASIS, | ||
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | ||
* See the License for the specific language governing permissions and | ||
* limitations under the License. | ||
*/ | ||
|
||
'use strict'; | ||
|
||
// MODULES // | ||
|
||
var bench = require( '@stdlib/bench' ); | ||
var uniform = require( '@stdlib/random/array/uniform' ); | ||
var isnan = require( '@stdlib/math/base/assert/is-nan' ); | ||
var Float32Array = require( '@stdlib/array/float32' ); | ||
var pkg = require( './../package.json' ).name; | ||
var csignumf = require( './../lib' ); | ||
|
||
|
||
// VARIABLES // | ||
|
||
var options = { | ||
'dtype': 'float32' | ||
}; | ||
|
||
|
||
// MAIN // | ||
|
||
bench( pkg+':strided', function benchmark( b ) { | ||
var out; | ||
var z; | ||
var N; | ||
var i; | ||
var j; | ||
|
||
N = 50; | ||
z = uniform( N*2, -500.0, 500.0, options ); | ||
out = new Float32Array( 2 ); | ||
|
||
b.tic(); | ||
for ( i = 0; i < b.iterations; i++ ) { | ||
j = ( i % N ) * 2; | ||
out = csignumf.strided( z, 1, j, out, 1, 0 ); | ||
if ( typeof out !== 'object' ) { | ||
b.fail( 'should return an object' ); | ||
} | ||
} | ||
b.toc(); | ||
if ( isnan( out[ 0 ] ) || isnan( out[ 1 ] ) ) { | ||
b.fail( 'should not return NaN' ); | ||
} | ||
b.pass( 'benchmark finished' ); | ||
b.end(); | ||
}); |
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
@@ -1,7 +1,6 @@ | ||||||
|
||||||
{{alias}}( z ) | ||||||
Evaluates the signum function of a single-precision complex floating-point | ||||||
number. | ||||||
Evaluates the signum function of a single-precision | ||||||
complex floating-point number. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Any reason for this change? |
||||||
|
||||||
Parameters | ||||||
---------- | ||||||
|
@@ -15,13 +14,91 @@ | |||||
|
||||||
Examples | ||||||
-------- | ||||||
> var v = {{alias}}( new {{alias:@stdlib/complex/float32/ctor}}( -4.2, 5.5 ) ) | ||||||
> var Complex64 = {{alias:@stdlib/complex/float32/ctor}} | ||||||
<Function> | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. These changes should be reverted. |
||||||
> var realf = {{alias:@stdlib/complex/float32/real}} | ||||||
<Function> | ||||||
> var imagf = {{alias:@stdlib/complex/float32/imag}} | ||||||
<Function> | ||||||
> var v = {{alias}}( new Complex64( -4.2, 5.5 ) ) | ||||||
<Complex64> | ||||||
> var re = {{alias:@stdlib/complex/float32/real}}( v ) | ||||||
> var re = realf( v ) | ||||||
~-0.607 | ||||||
> var im = {{alias:@stdlib/complex/float32/imag}}( v ) | ||||||
> var im = imagf( v ) | ||||||
~0.795 | ||||||
|
||||||
|
||||||
{{alias}}.assign( re, im, out, stride, offset ) | ||||||
Evaluates the signum function and assigns the result to a | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Make sure the parameter names here match with the respective files. |
||||||
provided output array. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Description needs to be updated here too. |
||||||
|
||||||
Parameters | ||||||
---------- | ||||||
re: number | ||||||
Real component. | ||||||
|
||||||
im: number | ||||||
Imaginary component. | ||||||
|
||||||
out: Float32Array | ||||||
Output array. | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
Applies here and below. |
||||||
|
||||||
stride: integer | ||||||
Output stride length. | ||||||
|
||||||
offset: integer | ||||||
Starting index for output. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
out: Float32Array | ||||||
Output array. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
> var out = new Float32Array( 2 ); | ||||||
> {{alias}}.assign( -4.2, 5.5, out, 1, 0 ) | ||||||
<Float32Array>[ ~-0.607, ~0.795 ] | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same comment on using the same examples throughout for consistency. |
||||||
|
||||||
|
||||||
{{alias}}.strided( z, sz, oz, out, so, oo ) | ||||||
Evaluates the signum function for single-precision complex numbers | ||||||
stored in a real-valued strided input array and assigns | ||||||
the results to a strided output array. | ||||||
|
||||||
Parameters | ||||||
---------- | ||||||
z: Float32Array | ||||||
Input array containing interleaved real and imaginary components. | ||||||
|
||||||
sz: integer | ||||||
Input stride length. | ||||||
|
||||||
oz: integer | ||||||
Starting index for input. | ||||||
|
||||||
out: Float32Array | ||||||
Output array. | ||||||
|
||||||
so: integer | ||||||
Output stride length. | ||||||
|
||||||
oo: integer | ||||||
Starting index for output. | ||||||
|
||||||
Returns | ||||||
------- | ||||||
out: Float32Array | ||||||
Output array. | ||||||
|
||||||
Examples | ||||||
-------- | ||||||
> var z = new Float32Array( [ -4.2, 5.5 ] ); | ||||||
> var out = new Float32Array( 2 ); | ||||||
> {{alias}}.strided( z, 1, 0, out, 1, 0 ) | ||||||
<Float32Array>[ ~-0.607, ~0.795 ] | ||||||
|
||||||
|
||||||
See Also | ||||||
-------- | ||||||
|
Uh oh!
There was an error while loading. Please reload this page.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
No need to change the copyright year if you are making edits to a currently present file.