-
-
Notifications
You must be signed in to change notification settings - Fork 843
feat: add reduce
method to array/complex64
#1271
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
Merged
Merged
Changes from all commits
Commits
Show all changes
34 commits
Select commit
Hold shift + click to select a range
a34dd86
feat: add implementation and ts declaration to reduce method array/co…
Jaysukh-409 5c88777
feat: updated typescript declaration
Jaysukh-409 85c749c
feat: apply suggestion in implementation
Jaysukh-409 f9c9c5c
Apply suggestions from code review
kgryte 6d2ee68
Apply suggestions from code review
kgryte 58fa1c4
Apply suggestions from code review
kgryte 53b299a
Apply suggestions from code review
kgryte 199ab19
Apply suggestions from code review
kgryte f83df65
Apply suggestions from code review
kgryte e99521d
Apply suggestions from code review
kgryte 8a0ae80
Apply suggestions from code review
kgryte 1672d68
Merge branch 'develop' of https://github.com/stdlib-js/stdlib into re…
Jaysukh-409 2f33439
Merge branch 'reduce' of https://github.com/Jaysukh-409/stdlib into r…
Jaysukh-409 d2982f1
feat: added benchmark and update README
Jaysukh-409 bf1a24b
Apply suggestions from code review
kgryte db3bd3b
Apply suggestions from code review
kgryte 5b08331
Apply suggestions from code review
kgryte 39cabdb
Apply suggestions from code review
kgryte c82d5f8
Apply suggestions from code review
kgryte 67f4dae
Apply suggestions from code review
kgryte 26abe08
Apply suggestions from code review
kgryte ad19a46
Apply suggestions from code review
kgryte c6c12b6
Apply suggestions from code review
kgryte fdf608c
feat: added tests
Jaysukh-409 1934ab4
fix: lint error in benchmark
Jaysukh-409 856fa92
Apply suggestions from code review
kgryte 8f01c36
feat: updated tests
Jaysukh-409 f35837f
Apply suggestions from code review
kgryte 2a48fe9
Apply suggestions from code review
kgryte d087f6b
Apply suggestions from code review
kgryte f5ff8a7
Apply suggestions from code review
kgryte be872b3
Apply suggestions from code review
kgryte 9529b8e
Apply suggestions from code review
kgryte d94a052
Apply suggestions from code review
kgryte File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
lib/node_modules/@stdlib/array/complex64/benchmark/benchmark.reduce.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | ||
var caddf = require( '@stdlib/math/base/ops/caddf' ); | ||
var isComplexLike = require('@stdlib/assert/is-complex-like'); | ||
kgryte marked this conversation as resolved.
Show resolved
Hide resolved
|
||
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
104
lib/node_modules/@stdlib/array/complex64/benchmark/benchmark.reduce.length.js
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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' ); | ||
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(); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Uh oh!
There was an error while loading. Please reload this page.