Skip to content

Commit

Permalink
Auto-generated commit
Browse files Browse the repository at this point in the history
  • Loading branch information
stdlib-bot committed Feb 24, 2024
1 parent ac21148 commit 15e7395
Show file tree
Hide file tree
Showing 13 changed files with 620 additions and 51 deletions.
4 changes: 2 additions & 2 deletions .github/workflows/npm_downloads.yml
Original file line number Diff line number Diff line change
Expand Up @@ -86,8 +86,8 @@ jobs:
# Upload the download data:
- name: 'Upload data'
# Pin action to full length commit SHA corresponding to v3.1.3
uses: actions/upload-artifact@a8a3f3ad30e3422c9c7b888a15615d19a852ae32
# Pin action to full length commit SHA
uses: actions/upload-artifact@5d5d22a31266ced268874388b861e4b58bb5c2f3 # v4.3.1
with:
# Define a name for the uploaded artifact (ensuring a unique name for each job):
name: npm_downloads
Expand Down
14 changes: 4 additions & 10 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -124,16 +124,10 @@ jobs:
mv ./package.json.tmp ./package.json
fi
done
jq -r '.devDependencies | keys[]' ./package.json | while read -r dep; do
if [[ "$dep" != "@stdlib"* ]]; then
continue
fi
dep=$(echo "$dep" | xargs)
if ! find lib -name "*.js" -exec grep -q "$dep" {} + && ! grep -q -s "$dep" manifest.json && ! grep -q -s "$dep" include.gypi; then
jq --indent 2 "del(.devDependencies[\"$dep\"])" ./package.json > ./package.json.tmp
mv ./package.json.tmp ./package.json
fi
done
# Set `devDependencies` to an empty object:
jq --indent 2 '.devDependencies = {}' ./package.json > ./package.json.tmp
mv ./package.json.tmp ./package.json
# Remove CLI section:
find . -type f -name '*.md' -print0 | xargs -0 perl -0777 -i -pe "s/(\* \* \*\n+)?<section class=\"cli\">[\s\S]+?<\!\-\- \/.cli \-\->//"
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/test_bundles.yml
Original file line number Diff line number Diff line change
Expand Up @@ -168,8 +168,8 @@ jobs:

# Install Deno:
- name: 'Install Deno'
# Pin action to full length commit SHA corresponding to v1.1.2
uses: denoland/setup-deno@61fe2df320078202e33d7d5ad347e7dcfa0e8f31
# Pin action to full length commit SHA
uses: denoland/setup-deno@041b854f97b325bd60e53e9dc2de9cb9f9ac0cba # v1.1.4
with:
deno-version: vx.x.x

Expand Down
4 changes: 4 additions & 0 deletions CONTRIBUTORS
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
#
# Contributors listed in alphabetical order.

Aditya Sapra <[email protected]>
Ali Salesi <[email protected]>
Amit Jimiwal <[email protected]>
Athan Reines <[email protected]>
Expand All @@ -13,6 +14,7 @@ Daniel Killenberger <[email protected]>
Dominik Moritz <[email protected]>
Dorrin Sotoudeh <[email protected]>
Frank Kovacs <[email protected]>
GUNJ JOSHI <[email protected]>
Harshita Kalani <[email protected]>
James Gelok <[email protected]>
Jaysukh Makvana <[email protected]>
Expand All @@ -21,6 +23,7 @@ Joey Reed <[email protected]>
Jordan Gallivan <[email protected]>
Joris Labie <[email protected]>
Justin Dennison <[email protected]>
Karthik Prakash <[email protected]>
Marcus Fantham <[email protected]>
Matt Cochrane <[email protected]>
Milan Raj <[email protected]>
Expand All @@ -36,6 +39,7 @@ Roman Stetsyk <[email protected]>
Ryan Seal <[email protected]>
Seyyed Parsa Neshaei <[email protected]>
Shraddheya Shendre <[email protected]>
Spandan Barve <[email protected]>
Stephannie Jiménez Gacha <[email protected]>
Yernar Yergaziyev <[email protected]>
orimiles5 <[email protected]>
Expand Down
58 changes: 56 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -1655,6 +1655,60 @@ var count = context.count;
// returns 3
```

<a name="method-reduce"></a>

#### Complex64Array.prototype.reduce( reducerFn\[, initialValue] )

Applies a provided callback function to each element of the array, in order, passing in the return value from the calculation on the preceding element and returning the accumulated result upon completion.

```javascript
var realf = require( '@stdlib/complex-realf' );
var imagf = require( '@stdlib/complex-imagf' );
var caddf = require( '@stdlib/math-base-ops-caddf' );

var arr = new Complex64Array( 3 );

arr.set( [ 1.0, 1.0 ], 0 );
arr.set( [ 2.0, 2.0 ], 1 );
arr.set( [ 3.0, 3.0 ], 2 );

var z = arr.reduce( caddf );
// returns <Complex64>

var re = realf( z );
// returns 6.0

var im = imagf( z );
// returns 6.0
```

The reducer function is provided four arguments:

- **acc**: accumulated result.
- **value**: current array element.
- **index**: current array element index.
- **arr**: the array on which this method was called.

By default, the function initializes the accumulated result to the first element in the array and passes the second array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the first array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.

```javascript
var realf = require( '@stdlib/complex-realf' );

function reducer( acc, v ) {
acc += realf( v );
return acc;
}

var arr = new Complex64Array( 3 );

arr.set( [ 1.0, 1.0 ], 0 );
arr.set( [ 2.0, 2.0 ], 1 );
arr.set( [ 3.0, 3.0 ], 2 );

var z = arr.reduce( reducer, 0.0 );
// returns 6.0
```

<a name="method-reverse"></a>

#### Complex64Array.prototype.reverse()
Expand Down Expand Up @@ -2312,8 +2366,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-complex64.svg
[npm-url]: https://npmjs.org/package/@stdlib/array-complex64

[test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=v0.2.0
[test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml?query=branch:v0.2.0
[test-image]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml/badge.svg?branch=main
[test-url]: https://github.com/stdlib-js/array-complex64/actions/workflows/test.yml?query=branch:main

[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-complex64/main.svg
[coverage-url]: https://codecov.io/github/stdlib-js/array-complex64?branch=main
Expand Down
52 changes: 52 additions & 0 deletions benchmark/benchmark.reduce.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,52 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 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-harness' );
var caddf = require( '@stdlib/math-base-ops-caddf' );
var isComplexLike = require('@stdlib/assert-is-complex-like');
var pkg = require( './../package.json' ).name;
var Complex64Array = require( './../lib' );


// MAIN //

bench( pkg+':reduce', function benchmark( b ) {
var out;
var arr;
var i;

arr = new Complex64Array( [ 1, 2, 3, 4, 5, 6 ] );

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.reduce( caddf );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isComplexLike( out ) ) {
b.fail( 'should return a complex number' );
}
b.pass( 'benchmark finished' );
b.end();
});
104 changes: 104 additions & 0 deletions benchmark/benchmark.reduce.length.js
Original file line number Diff line number Diff line change
@@ -0,0 +1,104 @@
/**
* @license Apache-2.0
*
* Copyright (c) 2023 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-harness' );
var pow = require( '@stdlib/math-base-special-pow' );
var caddf = require( '@stdlib/math-base-ops-caddf' );
var isComplexLike = require('@stdlib/assert-is-complex-like');
var Complex64 = require( '@stdlib/complex-float32' );
var pkg = require( './../package.json' ).name;
var Complex64Array = require( './../lib' );


// FUNCTIONS //

/**
* Creates a benchmark function.
*
* @private
* @param {PositiveInteger} len - array length
* @returns {Function} benchmark function
*/
function createBenchmark( len ) {
var arr;
var i;

arr = [];
for ( i = 0; i < len; i++ ) {
arr.push( new Complex64( i, i ) );
}
arr = new Complex64Array( arr );

return benchmark;

/**
* Benchmark function.
*
* @private
* @param {Benchmark} b - benchmark instance
*/
function benchmark( b ) {
var out;
var i;

b.tic();
for ( i = 0; i < b.iterations; i++ ) {
out = arr.reduce( caddf );
if ( typeof out !== 'object' ) {
b.fail( 'should return an object' );
}
}
b.toc();
if ( !isComplexLike( out ) ) {
b.fail( 'should return a complex number' );
}
b.pass( 'benchmark finished' );
b.end();
}
}


// MAIN //

/**
* Main execution sequence.
*
* @private
*/
function main() {
var len;
var min;
var max;
var f;
var i;

min = 1; // 10^min
max = 6; // 10^max

for ( i = min; i <= max; i++ ) {
len = pow( 10, i );
f = createBenchmark( len );
bench( pkg+':reduce:len='+len, f );
}
}

main();
2 changes: 1 addition & 1 deletion dist/index.js

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions dist/index.js.map

Large diffs are not rendered by default.

Loading

0 comments on commit 15e7395

Please sign in to comment.