Skip to content
Open
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
65 changes: 56 additions & 9 deletions lib/node_modules/@stdlib/math/base/special/cceil/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -68,6 +68,55 @@ var im = imag( v );
// returns 3.0
```

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

Rounds each component of a double-precision complex floating-point number toward positive infinity and assigns results to a provided output array.

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

var out = new Float64Array( 2 );
var v = cceil.assign( -1.5, 2.5, out, 1, 0 );
// returns <Float64Array>[ -1.0, 3.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`.

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

Rounds each component of a double-precision complex floating-point number stored in a real-valued strided array view toward positive infinity and assigns results to a provided strided output array.

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

var z = new Float64Array( [ -1.5, 2.5 ] );
var out = new Float64Array( 2 );

var v = cceil.strided( z, 1, 0, out, 1, 0 );
// returns <Float64Array>[ -1.0, 3.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 @@ -79,18 +128,16 @@ var im = imag( v );
<!-- eslint no-undef: "error" -->

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

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

var z;
var i;
for ( i = 0; i < 100; i++ ) {
z = new Complex128( rand(), rand() );
console.log( 'cceil(%s) = %s', z, cceil( z ) );
}
// Round each component of each complex number toward positive infinity:
logEachMap( 'cceil(%s) = %s', arr, cceil );
```

</section>
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, -500.0, 500.0, options );
im = uniform( N, -500.0, 500.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,37 +21,43 @@
// 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 Complex128 = require( '@stdlib/complex/float64/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );
var pkg = require( './../package.json' ).name;
var cceil = 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( -500.0, 500.0 ), uniform( -500.0, 500.0 ) ),
new Complex128( uniform( -500.0, 500.0 ), uniform( -500.0, 500.0 ) )
];
zbuf = uniform( 200, -500.0, 500.0, options );
z = new Complex128Array( zbuf.buffer );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = cceil( values[ i%values.length ] );
y = cceil( z.get( i%100 ) );
if ( isnan( real( y ) ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( imag( y ) ) ) {
b.fail( 'should not return not NaN' );
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
b.end();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -22,10 +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 Complex128 = require( '@stdlib/complex/float64/ctor' );
var Complex128Array = require( '@stdlib/array/complex128' );
var real = require( '@stdlib/complex/float64/real' );
var imag = require( '@stdlib/complex/float64/imag' );
var tryRequire = require( '@stdlib/utils/try-require' );
var format = require( '@stdlib/string/format' );
var pkg = require( './../package.json' ).name;
Expand All @@ -37,29 +38,31 @@ var cceil = tryRequire( resolve( __dirname, './../lib/native.js' ) );
var opts = {
'skip': ( cceil instanceof Error )
};
var options = {
'dtype': 'float64'
};


// MAIN //

bench( format( '%s::native', pkg ), opts, function benchmark( b ) {
var values;
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, -500.0, 500.0, options );
z = new Complex128Array( zbuf.buffer );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
y = cceil( values[ i%values.length ] );
y = cceil( z.get( i%100 ) );
if ( isnan( real( y ) ) ) {
b.fail( 'should not return NaN' );
}
}
b.toc();
if ( isnan( real( y ) ) ) {
if ( isnan( imag( y ) ) ) {
b.fail( 'should not return NaN' );
}
b.pass( 'benchmark finished' );
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, -500.0, 500.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();
});
Loading
Loading