-
-
Notifications
You must be signed in to change notification settings - Fork 866
feat: add C ndarray
implementation for stats/base/dmeanvarpn
#4720
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
feat: add C ndarray
implementation for stats/base/dmeanvarpn
#4720
Conversation
--- 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: na - task: lint_package_json status: na - task: lint_repl_help status: na - task: lint_javascript_src status: passed - 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: passed - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
lib/node_modules/@stdlib/stats/base/dmeanvarpn/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/stats/base/dmeanvarpn/benchmark/c/benchmark.length.c
Outdated
Show resolved
Hide resolved
Coverage Report
The above coverage report was generated for the changes in this PR. |
/stdlib update-copyright-years |
--- 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: na - task: lint_c_examples status: na - task: lint_c_benchmarks status: passed - task: lint_c_tests_fixtures status: na - task: lint_shell status: na - task: lint_typescript_declarations status: na - task: lint_typescript_tests status: na - task: lint_license_headers status: passed --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: na - task: run_c_examples status: na - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: passed - task: run_c_benchmarks status: passed - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: na - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: na ---
stats/base/dmeanvarpn
ndarray
implementation for stats/base/dmeanvarpn
--- 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: na - 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: 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: passed - task: lint_c_examples status: passed - 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 --- --- type: pre_push_report description: Results of running various checks prior to pushing changes. report: - task: run_javascript_examples status: passed - task: run_c_examples status: passed - task: run_cpp_examples status: na - task: run_javascript_readme_examples status: na - task: run_c_benchmarks status: na - task: run_cpp_benchmarks status: na - task: run_fortran_benchmarks status: na - task: run_javascript_benchmarks status: passed - task: run_julia_benchmarks status: na - task: run_python_benchmarks status: na - task: run_r_benchmarks status: na - task: run_javascript_tests status: passed ---
double x[] ={ 1.0, -2.0, 2.0 }; | ||
double out[2]; | ||
stdlib_strided_dmeanvarpn( x.length, 1, x, 1, out, 1 ); | ||
// Out = [ ~0.3333, ~4.3333 ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
double x[] ={ 1.0, -2.0, 2.0 }; | |
double out[2]; | |
stdlib_strided_dmeanvarpn( x.length, 1, x, 1, out, 1 ); | |
// Out = [ ~0.3333, ~4.3333 ] | |
const double x[] ={ 1.0, -2.0, 2.0 }; | |
double out[] = { 0.0, 0.0 }; | |
stdlib_strided_dmeanvarpn( x.length, 1, x, 1, out, 1 ); |
- **correction**: `[in] double` degrees of freedom adjustment. | ||
- **X**: `[in] double*` input array. | ||
- **strideX**: `[in] CBLAS_INT` stride length for `X`. | ||
- **Out**: `[in] double*` Output array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **Out**: `[in] double*` Output array. | |
- **Out**: `[out] double*` Output array. |
const double x[] = { 1.0, -2.0, 2.0 }; | ||
|
||
stdlib_strided_dmeanvarpn_ndarray( x.length, 1, x, 1, 0, out, 1, 0 ); | ||
// Out = [ ~0.3333, ~4.3333 ] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no declaration for Out
here
- **X**: `[in] double*` input array. | ||
- **strideX**: `[in] CBLAS_INT` stride length for `X`. | ||
- **offsetX**: `[in] CBLAS_INT` `X` starting index. | ||
- **Out**: `[in] double*` Output array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
- **Out**: `[in] double*` Output array. | |
- **Out**: `[out] double*` Output array. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is also missing changes in the JavaScript docs regarding removing the usage of math/base/special/floor
in examples
@@ -17,7 +17,6 @@ | |||
*/ | |||
|
|||
#include "stdlib/stats/base/dmeanvarpn.h" | |||
#include "stdlib/blas/base/shared.h" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
why is this being removed? it should be there since we're wrapping function calls in API_SUFFIX
which comes from this header
@@ -16,72 +16,76 @@ | |||
* limitations under the License. | |||
*/ | |||
|
|||
#include "stdlib/stats/base/dmeanvarpn.h" | |||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
no need for extra newline
* ## Method | ||
* | ||
* - This implementation uses a two-pass approach, as suggested by Neely (1966). | ||
* | ||
* ## References | ||
* | ||
* - Neely, Peter M. 1966. "Comparison of Several Algorithms for Computation of Means, Standard Deviations and Correlation Coefficients." _Communications of the ACM_ 9 (7). Association for Computing Machinery: 496–99. doi:[10.1145/365719.365958](https://doi.org/10.1145/365719.365958). | ||
* - Schubert, Erich, and Michael Gertz. 2018. "Numerically Stable Parallel Computation of (Co-)Variance." In _Proceedings of the 30th International Conference on Scientific and Statistical Database Management_. New York, NY, USA: Association for Computing Machinery. doi:[10.1145/3221269.3223036](https://doi.org/10.1145/3221269.3223036). | ||
* |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
references are important, no need to remove them
CBLAS_INT ix; | ||
CBLAS_INT io; | ||
CBLAS_INT n; | ||
double mu; | ||
double dN; | ||
double M2; | ||
double M; | ||
double d; | ||
double c; | ||
double n; | ||
double i; | ||
|
||
if ( strideX < 0 ) { | ||
ix = (1-N) * strideX; | ||
} else { | ||
ix = 0; | ||
} | ||
if ( strideOut < 0 ) { | ||
io = -strideOut; | ||
} else { | ||
io = 0; | ||
} | ||
ix = offsetX; | ||
io = offsetOut; | ||
if ( N <= 0 ) { | ||
Out[ io ] = 0.0 / 0.0; // NaN | ||
Out[ io+strideOut ] = 0.0 / 0.0; // NaN | ||
Out[ io ] = 0.0/0.0; | ||
Out[ io + strideOut ] = 0.0/0.0; | ||
return; | ||
} | ||
dN = (double)N; | ||
n = dN - correction; | ||
n = N - correction; | ||
if ( N == 1 || strideX == 0 ) { | ||
Out[ io ] = X[ ix ]; | ||
if ( n <= 0.0 ) { | ||
Out[ io+strideOut ] = 0.0 / 0.0; // NaN | ||
Out[ io+strideOut ] = 0.0/0.0; | ||
} else { | ||
Out[ io+strideOut ] = 0.0; | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this is copied from the JS ndarray implementation, i would prefer that you refactor the existing C implementation only
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this would avoid implicit typecasting etc, for eg see changes on line 101
if ( N == 1 || strideX == 0 ) { | ||
Out[ io ] = X[ ix ]; | ||
if ( n <= 0.0 ) { | ||
Out[ io+strideOut ] = 0.0 / 0.0; // NaN | ||
Out[ io+strideOut ] = 0.0/0.0; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Out[ io+strideOut ] = 0.0/0.0; | |
Out[ io+strideOut ] = 0.0 / 0.0; // NaN |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
same comment for all other instances
Thank you for working on this pull request. However, we cannot accept your contribution as the issue this pull request seeks to resolve has already been addressed in a different pull request or commit. Thank you again for your interest in stdlib, and we look forward to reviewing your future contributions. |
Resolves None.
Description
This pull request:
ndarray
implementation forstats/base/dmeanvarpn
.Related Issues
This pull request:
Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers