feat: add lapack/base/dlas2#2833
Conversation
| var out = new Float64Array( 2 ); | ||
| dlas2( 1.0, 2.0, 3.0, out ); | ||
| console.log( out ); |
There was a problem hiding this comment.
@Pranavchiku You need to go beyond just copy-pasting a prior example. This applies to all your PRs.
| A = ( randu() * 100.0 ) - 50.0; | ||
| B = ( randu() * 100.0 ) - 50.0; | ||
| C = ( randu() * 100.0 ) - 50.0; | ||
| out = new Float64Array( 2 ); |
There was a problem hiding this comment.
Why are you doing this within the b.tic()? This benchmark needs to be refactored. It is also not clear why were are reusing out values in subsequent iterations.
| b.tic(); | ||
| for ( i = 0; i < b.iterations; i++ ) { | ||
| out = dlas2( A, B, C, out, 1, 0 ); | ||
| A = out[ i%out.length ]; |
| if ( fhmx === 0.0 ) { | ||
| ssmax = ga; | ||
| } else { | ||
| ssmax = max( fhmx, ga ) * sqrt( 1.0 + pow( min( fhmx, ga ) / max( fhmx, ga ), 2 ) ); |
There was a problem hiding this comment.
For squaring numbers, use abs2. It is a much lighter weight dependency and will be faster in general.
| } else { | ||
| as = 1.0 + ( fhmn / fhmx ); | ||
| at = ( fhmx - fhmn ) / fhmx; | ||
| c = 1.0 / ( sqrt( 1.0 + pow( as * au, 2 ) ) + sqrt( 1.0 + pow( at * au, 2 ) ) ); |
|
|
||
| out = new Float64Array( 2 ); | ||
| out = dlas2( 2.0, 3.0, 4.0, out ); | ||
| expected = new Float64Array( [ 1.5513263285176897, 5.1568776039816795 ] ); |
There was a problem hiding this comment.
@Pranavchiku How did you compute these expected values? R, Mathematica, something else? It would be good to include a comment here (as we do in other parts of the codebase) specifying how expected values were computed.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function computes the eigenvalues of a 2x2 symmetric matrix', function test( t ) { |
There was a problem hiding this comment.
I believe you are computing singular values, not eigenvalues values. Applies here and elsewhere.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function supports complex access pattern to store computed values', function test( t ) { |
There was a problem hiding this comment.
@Pranavchiku You need to include the tests from test.dlas2.js here. Don't take shortcuts. It is not a given that the underlying implementation is the same for the main and ndarray exports. Always test to the interface, NOT the implementation.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { |
There was a problem hiding this comment.
| tape( 'the function supports accessing elements in reverse order to store computed values', function test( t ) { | |
| tape( 'the function supports a negative `out` stride', function test( t ) { |
Follow the conventions found elsewhere for test descriptions.
| t.end(); | ||
| }); | ||
|
|
||
| tape( 'the function supports complex access pattern to store computed values', function test( t ) { |
There was a problem hiding this comment.
Having such a test is fine ("complex access patterns"), but you also should have tests for specific behavior. E.g., "the function supports an out stride", "the function supports supports an out offset", etc, where you hold everything constant except for the behavior you want to test. Tests should build on one another.
Coverage Report
The above coverage report was generated for the changes in this PR. |
---
type: pre_commit_static_analysis_report
description: Results of running static analysis checks when committing changes.
report:
- task: lint_filenames
status: passed
- task: lint_editorconfig
status: passed
- task: lint_markdown
status: passed
- task: lint_package_json
status: passed
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: passed
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: passed
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: na
- task: lint_c_examples
status: na
- task: lint_c_benchmarks
status: na
- task: lint_c_tests_fixtures
status: na
- task: lint_shell
status: na
- task: lint_typescript_declarations
status: passed
- task: lint_typescript_tests
status: passed
- task: lint_license_headers
status: passed
---
Towards #2464.
Description
This pull request adds JS implementation for
lapack/base/dlas2.Related Issues
NA
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers