Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
82 changes: 64 additions & 18 deletions lib/node_modules/@stdlib/math/base/special/ccis/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -69,6 +69,55 @@ v = ccis( z );
// returns <Complex128>[ ~0.540, ~0.841 ]
```

#### ccis.assign( re, im, out, strideOut, offsetOut )

Evaluates the [cis][cis] function for a double-precision complex floating-point number and assigns results to a provided output array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var out = new Float64Array( 2 );
var v = ccis.assign( 0.0, 0.0, out, 1, 0 );
// returns <Float64Array>[ 1.0, 0.0 ]

var bool = ( out === v );
// returns true
```

The function supports the following parameters:

- **re**: real component.
- **im**: imaginary component.
- **out**: output array.
- **strideOut**: stride length for `out`.
- **offsetOut**: starting index for `out`.

#### ccis.strided( z, sz, oz, out, so, oo )

Evaluates the [cis][cis] function for a double-precision complex floating-point number stored in a real-valued strided array view and assigns results to a provided strided output array.

```javascript
var Float64Array = require( '@stdlib/array/float64' );

var z = new Float64Array( [ 0.0, 0.0 ] );
var out = new Float64Array( 2 );

var v = ccis.strided( z, 1, 0, out, 1, 0 );
// returns <Float64Array>[ 1.0, 0.0 ]

var bool = ( out === v );
// returns true
```

The function supports the following parameters:

- **z**: complex number strided array view.
- **sz**: stride length for `z`.
- **oz**: starting index for `z`.
- **out**: output array.
- **so**: stride length for `out`.
- **oo**: starting index for `out`.

</section>

<!-- /.usage -->
Expand All @@ -80,19 +129,16 @@ v = ccis( z );
<!-- eslint no-undef: "error" -->

```javascript
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var uniform = require( '@stdlib/random/base/uniform' );
var Complex128Array = require( '@stdlib/array/complex128' );
var uniform = require( '@stdlib/random/array/uniform' );
var logEachMap = require( '@stdlib/console/log-each-map' );
var ccis = require( '@stdlib/math/base/special/ccis' );

var z1;
var z2;
var i;
// Create an array of random numbers:
var arr = new Complex128Array( uniform( 200, -50.0, 50.0 ) );

for ( i = 0; i < 100; i++ ) {
z1 = new Complex128( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) );
z2 = ccis( z1 );
console.log( 'ccis(%s) = %s', z1.toString(), z2.toString() );
}
// Compute the cis function of each number in the array:
logEachMap( 'ccis(%s) = %s', arr, ccis );
```

</section>
Expand Down Expand Up @@ -177,7 +223,7 @@ stdlib_complex128_t stdlib_base_ccis( const stdlib_complex128_t z );
#include "stdlib/complex/float64/reim.h"
#include <stdio.h>

int main() {
int main( void ) {
const stdlib_complex128_t x[] = {
stdlib_complex128( 3.14, 1.5 ),
stdlib_complex128( -3.14, 1.5 ),
Expand All @@ -187,17 +233,17 @@ int main() {

stdlib_complex128_t v;
stdlib_complex128_t y;
double re;
double im;
double re1;
double im1;
double re2;
double im2;
int i;
for ( i = 0; i < 4; i++ ) {
v = x[ i ];
stdlib_complex128_reim( v, &re, &im );
printf( "z = %lf + %lfi\n", re, im );

y = stdlib_base_ccis( v );
stdlib_complex128_reim( y, &re, &im );
printf( "ccis(z) = %lf + %lfi\n", re, im );
stdlib_complex128_reim( v, &re1, &im1 );
stdlib_complex128_reim( y, &re2, &im2 );
printf( "ccis(%lf + %lfi) = %lf + %lfi\n", re1, im1, re2, im2 );
}
}
```
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,69 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var assign = require( './../lib' ).assign;


// VARIABLES //

var options = {
'dtype': 'float64'
};


// MAIN //

bench( format( '%s:assign', pkg ), function benchmark( b ) {
var out;
var re;
var im;
var N;
var i;
var j;

N = 100;
re = uniform( N, -50.0, 50.0, options );
im = uniform( N, -50.0, 50.0, options );

out = new Float64Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = i % N;
out = assign( re[ j ], im[ 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
Expand Up @@ -21,30 +21,36 @@
// MODULES //

var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var pkg = require( './../package.json' ).name;
var ccis = require( './../lib' );


// VARIABLES //

var options = {
'dtype': 'float64'
};


// MAIN //

bench( pkg, function benchmark( b ) {
var values;
var zbuf;
var z;
var y;
var i;

values = [
new Complex128( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) ),
new Complex128( uniform( -50.0, 50.0 ), uniform( -50.0, 50.0 ) )
];
zbuf = uniform( 200, -50.0, 50.0, options );
z = new Complex128Array( zbuf.buffer );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = ccis( values[ i%values.length ] );
y = ccis( z.get( i%100 ) );
if ( isnan( real( y ) ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,11 +22,11 @@

var resolve = require( 'path' ).resolve;
var bench = require( '@stdlib/bench' );
var uniform = require( '@stdlib/random/base/uniform' );
var uniform = require( '@stdlib/random/array/uniform' );
var isnan = require( '@stdlib/math/base/assert/is-nan' );
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );
var Complex128 = require( '@stdlib/complex/float64/ctor' );
var tryRequire = require( '@stdlib/utils/try-require' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
Expand All @@ -38,25 +38,25 @@ var ccis = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( ccis instanceof Error )
};
var options = {
'dtype': 'float64'
};


// MAIN //

bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
var values;
var y;
var zbuf;
var z;
var y;
var i;

values = [
new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ),
new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) )
];
zbuf = uniform( 200, -50.0, 50.0, options );
z = new Complex128Array( zbuf.buffer );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
z = values[ i%values.length ];
y = ccis( z );
y = ccis( z.get( i%100 ) );
if ( isnan( real( y ) ) ) {
b.fail( 'should not return NaN' );
}
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,67 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2026 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 Float64Array = require( '@stdlib/array/float64' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
var strided = require( './../lib' ).strided;


// VARIABLES //

var options = {
'dtype': 'float64'
};


// MAIN //

bench( format( '%s:strided', pkg ), function benchmark( b ) {
var out;
var z;
var N;
var i;
var j;

N = 50;
z = uniform( N*2, -50.0, 50.0, options );

out = new Float64Array( 2 );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
j = ( i % N ) * 2;
out = 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
Expand Up @@ -20,9 +20,10 @@
#include <stdio.h>
#include <math.h>
#include <complex.h>
#include <time.h>
#include <sys/time.h>

#define NAME "cis"
#define NAME "ccis"
#define ITERATIONS 1000000
#define REPEATS 3

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import BenchmarkTools
using Printf

# Benchmark variables:
name = "cis";
name = "ccis";
repeats = 3;

"""
Expand Down Expand Up @@ -136,7 +136,7 @@ function main()
@printf( "# julia::%s\n", name );
results = benchmark();
print_results( results[ 1 ], results[ 2 ] );
@printf( "ok %d benchmark finished\n", i );
@printf( "ok %d benchmark finished\n", i );
end
print_summary( repeats, repeats );
end
Expand Down
Loading
Loading