feat: add stats/strided/distances/dminkowski#10567
feat: add stats/strided/distances/dminkowski#10567nakul-krishnakumar wants to merge 12 commits intostdlib-js:developfrom
stats/strided/distances/dminkowski#10567Conversation
---
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: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- task: lint_c_benchmarks
status: missing_dependencies
- 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
---
---
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: na
- task: lint_repl_help
status: passed
- task: lint_javascript_src
status: passed
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: passed
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- task: lint_c_examples
status: missing_dependencies
- 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
---
|
Please note that the |
Coverage Report
The above coverage report was generated for the changes in this PR. |
|
@nakul-krishnakumar Mind resolving the C lint errors? |
How do you want me to fix the error? Currently it raises error because of the int main( void ) {
double elapsed;
double *powers;
int count;
int iter;
int len;
int i;
int j;
int p;
// Use the current time to seed the random number generator:
srand( time( NULL ) );
print_version();
count = 0;
powers = (double[]) { 1.0, 2.0, 10.0, INFINITY };
for ( i = MIN; i <= MAX; i++ ) {
len = pow( 10, i );
iter = ITERATIONS / pow( 10, i-1 );
for ( p = 0; p < 4; p++ ) {
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:len=%d:p=%.2f\n", NAME, len, powers[ p ] );
elapsed = benchmark1( iter, len, powers[ p ] );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
for ( j = 0; j < REPEATS; j++ ) {
count += 1;
printf( "# c::%s:ndarray:len=%d:p=%.2f\n", NAME, len, powers[ p ] );
elapsed = benchmark2( iter, len, powers[ p ] );
print_results( iter, elapsed );
printf( "ok %d benchmark finished\n", count );
}
}
}
print_summary( count, count );
}Can I instead do |
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Co-authored-by: Nakul Krishnakumar <nakulkrishnakumar86@gmail.com> Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/docs/types/test.ts
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/examples/c/example.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/dminkowski.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/dminkowski.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Outdated
Show resolved
Hide resolved
| s = abs( x[ ox ] - y[ oy ] ); | ||
| d = pow( s, p ); | ||
| ox += strideX; | ||
| oy += strideY; |
There was a problem hiding this comment.
What is the point of unrolling the first element? Could you not just initialize d = 0.0 and then have the loop go from i = 0 to i < N? Seems like this is currently just wasting additional characters without a strong motivation.
There was a problem hiding this comment.
What is the point of unrolling the first element? Could you not just initialize
d = 0.0and then have the loop go fromi = 0toi < N? Seems like this is currently just wasting additional characters without a strong motivation.
I was just trying to mimic the implementation of dchebyshev where it is useful as it takes the max of residuals, but here as you said it does look redundant. Thank you for pointing that out. We will have to do the same refactoring for stats/strided/distances/dcityblock too then.
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.ndarray.js
Outdated
Show resolved
Hide resolved
...ode_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/benchmark.ndarray.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/lib/ndarray.js
Outdated
Show resolved
Hide resolved
Co-authored-by: Athan <kgryte@gmail.com> Signed-off-by: Nakul Krishnakumar <nakulkrishnakumar86@gmail.com>
---
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: na
- task: lint_repl_help
status: na
- task: lint_javascript_src
status: na
- task: lint_javascript_cli
status: na
- task: lint_javascript_examples
status: na
- task: lint_javascript_tests
status: na
- task: lint_javascript_benchmarks
status: na
- task: lint_python
status: na
- task: lint_r
status: na
- task: lint_c_src
status: missing_dependencies
- 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: na
- task: lint_license_headers
status: passed
---
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Nakul Krishnakumar <nakulkrishnakumar86@gmail.com>
lib/node_modules/@stdlib/stats/strided/distances/dminkowski/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
|
|
||
| min = 1; // 10^min | ||
| max = 6; // 10^max | ||
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); |
There was a problem hiding this comment.
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); | |
| p = new Float64Array( [ 1.0, 2.0, 10.0, PINF ] ); |
Use the stdlib constant.
|
|
||
| min = 1; // 10^min | ||
| max = 6; // 10^max | ||
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); |
There was a problem hiding this comment.
Use the stdlib constant.
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); | |
| p = new Float64Array( [ 1.0, 2.0, 10.0, PINF ] ); |
|
|
||
| min = 1; // 10^min | ||
| max = 6; // 10^max | ||
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); |
There was a problem hiding this comment.
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); | |
| p = new Float64Array( [ 1.0, 2.0, 10.0, PINF ] ); |
|
|
||
| min = 1; // 10^min | ||
| max = 6; // 10^max | ||
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); |
There was a problem hiding this comment.
| p = new Float64Array( [ 1.0, 2.0, 10.0, Infinity ] ); | |
| p = new Float64Array( [ 1.0, 2.0, 10.0, PINF ] ); |
| * Main execution sequence. | ||
| */ | ||
| int main( void ) { | ||
| const double powers[ 4 ] = { 1.0, 2.0, 10.0, INFINITY }; |
There was a problem hiding this comment.
If we really want to be pedantic, you can also use the stdlib constant here, as well.
kgryte
left a comment
There was a problem hiding this comment.
Other than the use of PINF, this PR is looking good.
Resolves None.
Description
This pull request:
stats/strided/distances/dminkowski.Related Issues
This pull request has the following related issues:
Questions
No.
Other
No.
Checklist
AI Assistance
If you answered "yes" above, how did you use AI assistance?
Disclosure
None.
@stdlib-js/reviewers