Skip to content

Commit 9bee827

Browse files
committed
Auto-generated commit
1 parent f915e84 commit 9bee827

12 files changed

Lines changed: 545 additions & 15 deletions

.npmignore

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -29,8 +29,9 @@ branches.md
2929
.postinstall.json
3030
Makefile
3131

32-
# Ignore `binding.gyp` file to avoid compilation of native addon when installing package:
32+
# Ignore files to avoid compilation of native addon when installing package:
3333
binding.gyp
34+
include.gypi
3435

3536
# Directories #
3637
###############

CONTRIBUTORS

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,18 +3,21 @@
33
# Contributors listed in alphabetical order.
44

55
Aditya Sapra <110766802+adityacodes30@users.noreply.github.com>
6+
AgPriyanshu18 <113460573+AgPriyanshu18@users.noreply.github.com>
67
Ali Salesi <ali_sal1381@yahoo.com>
78
Amit Jimiwal <amitjimiwal45@gmail.com>
89
Athan Reines <kgryte@gmail.com>
910
Brendan Graetz <bguiz@users.noreply.github.com>
1011
Bruno Fenzl <brunofenzl@gmail.com>
12+
Chinmay J <86140365+JawHawk@users.noreply.github.com>
1113
Christopher Dambamuromo <chridam@gmail.com>
1214
Dan Rose <danoftheroses@gmail.com>
1315
Daniel Killenberger <daniel.killenberger@gmail.com>
1416
Dominik Moritz <domoritz@gmail.com>
1517
Dorrin Sotoudeh <dorrinsotoudeh123@gmail.com>
1618
Frank Kovacs <fran70kk@gmail.com>
1719
GUNJ JOSHI <gunjjoshi8372@gmail.com>
20+
Golden <103646877+AuenKr@users.noreply.github.com>
1821
Harshita Kalani <harshitakalani02@gmail.com>
1922
James Gelok <jdgelok@gmail.com>
2023
Jaysukh Makvana <jaysukhmakvana2004@gmail.com>
@@ -24,6 +27,7 @@ Jordan Gallivan <115050475+Jordan-Gallivan@users.noreply.github.com>
2427
Joris Labie <joris.labie1@gmail.com>
2528
Justin Dennison <justin1dennison@gmail.com>
2629
Karthik Prakash <116057817+skoriop@users.noreply.github.com>
30+
Khaldon <kahmd1444@gmail.com>
2731
Marcus Fantham <mfantham@users.noreply.github.com>
2832
Matt Cochrane <matthew.cochrane.eng@gmail.com>
2933
Milan Raj <rajsite@users.noreply.github.com>
@@ -34,12 +38,16 @@ Ognjen Jevremović <ognjenjevremovic@users.noreply.github.com>
3438
Philipp Burckhardt <pburckhardt@outlook.com>
3539
Prajwal Kulkarni <prajwalkulkarni76@gmail.com>
3640
Pranav Goswami <goswami.4@iitj.ac.in>
41+
Praneki <97080887+PraneGIT@users.noreply.github.com>
42+
Pratik <97464067+Pratik772846@users.noreply.github.com>
3743
Ricky Reusser <rsreusser@gmail.com>
3844
Robert Gislason <gztown2216@yahoo.com>
3945
Roman Stetsyk <25715951+romanstetsyk@users.noreply.github.com>
46+
Rutam <138517416+performant23@users.noreply.github.com>
4047
Ryan Seal <splrk@users.noreply.github.com>
4148
Seyyed Parsa Neshaei <spneshaei@users.noreply.github.com>
4249
Shraddheya Shendre <shendreshraddheya@gmail.com>
50+
Shubham <shubh622005@gmail.com>
4351
Spandan Barve <114365550+marsian83@users.noreply.github.com>
4452
Stephannie Jiménez Gacha <steff456@hotmail.com>
4553
Yernar Yergaziyev <yernar.yergaziyev@erg.kz>

README.md

Lines changed: 56 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1707,6 +1707,60 @@ var z = arr.reduce( reducer, 0.0 );
17071707
// returns 6.0
17081708
```
17091709

1710+
<a name="method-reduce-right"></a>
1711+
1712+
#### Complex128Array.prototype.reduceRight( reducerFn\[, initialValue] )
1713+
1714+
Applies a provided callback function to each element of the array, in reverse order, passing in the return value from the calculation on the following element and returning the accumulated result upon completion.
1715+
1716+
```javascript
1717+
var real = require( '@stdlib/complex-real' );
1718+
var imag = require( '@stdlib/complex-imag' );
1719+
var cadd = require( '@stdlib/math-base-ops-cadd' );
1720+
1721+
var arr = new Complex128Array( 3 );
1722+
1723+
arr.set( [ 1.0, 1.0 ], 0 );
1724+
arr.set( [ 2.0, 2.0 ], 1 );
1725+
arr.set( [ 3.0, 3.0 ], 2 );
1726+
1727+
var z = arr.reduceRight( cadd );
1728+
// returns <Complex128>
1729+
1730+
var re = real( z );
1731+
// returns 6.0
1732+
1733+
var im = imag( z );
1734+
// returns 6.0
1735+
```
1736+
1737+
The reducer function is provided four arguments:
1738+
1739+
- **acc**: accumulated result.
1740+
- **value**: current array element.
1741+
- **index**: current array element index.
1742+
- **arr**: the array on which this method was called.
1743+
1744+
By default, the function initializes the accumulated result to the last element in the array and passes the second-last array element as `value` during the first invocation of the provided callback. To begin accumulation from a different starting value and pass in the last array element as `value` during the first invocation of the provided callback, provide an `initialValue` argument.
1745+
1746+
```javascript
1747+
var real = require( '@stdlib/complex-real' );
1748+
1749+
function reducer( acc, v ) {
1750+
acc += real( v );
1751+
return acc;
1752+
}
1753+
1754+
var arr = new Complex128Array( 3 );
1755+
1756+
arr.set( [ 1.0, 1.0 ], 0 );
1757+
arr.set( [ 2.0, 2.0 ], 1 );
1758+
arr.set( [ 3.0, 3.0 ], 2 );
1759+
1760+
var z = arr.reduceRight( reducer, 0.0 );
1761+
// returns 6.0
1762+
```
1763+
17101764
<a name="method-reverse"></a>
17111765

17121766
#### Complex128Array.prototype.reverse()
@@ -2364,8 +2418,8 @@ Copyright &copy; 2016-2024. The Stdlib [Authors][stdlib-authors].
23642418
[npm-image]: http://img.shields.io/npm/v/@stdlib/array-complex128.svg
23652419
[npm-url]: https://npmjs.org/package/@stdlib/array-complex128
23662420

2367-
[test-image]: https://github.com/stdlib-js/array-complex128/actions/workflows/test.yml/badge.svg?branch=v0.2.1
2368-
[test-url]: https://github.com/stdlib-js/array-complex128/actions/workflows/test.yml?query=branch:v0.2.1
2421+
[test-image]: https://github.com/stdlib-js/array-complex128/actions/workflows/test.yml/badge.svg?branch=main
2422+
[test-url]: https://github.com/stdlib-js/array-complex128/actions/workflows/test.yml?query=branch:main
23692423

23702424
[coverage-image]: https://img.shields.io/codecov/c/github/stdlib-js/array-complex128/main.svg
23712425
[coverage-url]: https://codecov.io/github/stdlib-js/array-complex128?branch=main
Lines changed: 52 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,52 @@
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-harness' );
24+
var cadd = require( '@stdlib/math-base-ops-cadd' );
25+
var isComplexLike = require('@stdlib/assert-is-complex-like' );
26+
var pkg = require( './../package.json' ).name;
27+
var Complex128Array = require( './../lib' );
28+
29+
30+
// MAIN //
31+
32+
bench( pkg+':reduceRight', function benchmark( b ) {
33+
var out;
34+
var arr;
35+
var i;
36+
37+
arr = new Complex128Array( [ 1, 2, 3, 4, 5, 6 ] );
38+
39+
b.tic();
40+
for ( i = 0; i < b.iterations; i++ ) {
41+
out = arr.reduceRight( cadd );
42+
if ( typeof out !== 'object' ) {
43+
b.fail( 'should return an object' );
44+
}
45+
}
46+
b.toc();
47+
if ( !isComplexLike( out ) ) {
48+
b.fail( 'should return a complex number' );
49+
}
50+
b.pass( 'benchmark finished' );
51+
b.end();
52+
});
Lines changed: 104 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,104 @@
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-harness' );
24+
var pow = require( '@stdlib/math-base-special-pow' );
25+
var cadd = require( '@stdlib/math-base-ops-cadd' );
26+
var isComplexLike = require('@stdlib/assert-is-complex-like' );
27+
var Complex128 = require( '@stdlib/complex-float64' );
28+
var pkg = require( './../package.json' ).name;
29+
var Complex128Array = require( './../lib' );
30+
31+
32+
// FUNCTIONS //
33+
34+
/**
35+
* Creates a benchmark function.
36+
*
37+
* @private
38+
* @param {PositiveInteger} len - array length
39+
* @returns {Function} benchmark function
40+
*/
41+
function createBenchmark( len ) {
42+
var arr;
43+
var i;
44+
45+
arr = [];
46+
for ( i = 0; i < len; i++ ) {
47+
arr.push( new Complex128( i, i ) );
48+
}
49+
arr = new Complex128Array( arr );
50+
51+
return benchmark;
52+
53+
/**
54+
* Benchmark function.
55+
*
56+
* @private
57+
* @param {Benchmark} b - benchmark instance
58+
*/
59+
function benchmark( b ) {
60+
var out;
61+
var i;
62+
63+
b.tic();
64+
for ( i = 0; i < b.iterations; i++ ) {
65+
out = arr.reduceRight( cadd );
66+
if ( typeof out !== 'object' ) {
67+
b.fail( 'should return an object' );
68+
}
69+
}
70+
b.toc();
71+
if ( !isComplexLike( out ) ) {
72+
b.fail( 'should return a complex number' );
73+
}
74+
b.pass( 'benchmark finished' );
75+
b.end();
76+
}
77+
}
78+
79+
80+
// MAIN //
81+
82+
/**
83+
* Main execution sequence.
84+
*
85+
* @private
86+
*/
87+
function main() {
88+
var len;
89+
var min;
90+
var max;
91+
var f;
92+
var i;
93+
94+
min = 1; // 10^min
95+
max = 6; // 10^max
96+
97+
for ( i = min; i <= max; i++ ) {
98+
len = pow( 10, i );
99+
f = createBenchmark( len );
100+
bench( pkg+':reduceRight:len='+len, f );
101+
}
102+
}
103+
104+
main();

0 commit comments

Comments
 (0)