-
-
Notifications
You must be signed in to change notification settings - Fork 485
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 implementation for @stdlib/math/base/special/erfcx
#2040
Conversation
const fs = require('fs');
const convertJstoC = () => {
const string = fs.readFileSync("./erfcx_y100.js", "utf8");
const regex = /function/g;
const arg = /\(\s*([^)]+?)\s*\)/g; // regex to get args inside ()
const functionSplits = string.split("*/\n"); // split string using */ of the comment
const replaced = functionSplits.map((func) => {
const args = func.match(arg);
func = func.replaceAll("* @param {number} t -","* @param t ").replaceAll(" {number}","").replaceAll("* @private\n","").replaceAll("@returns ", "@return ").replaceAll(regex,"static double"); // convert all jsDoc types to C-Deoxygen as well as convert functions to statis double
if(args) {
func = func.replaceAll(args[0], "( const double t )"); // convert arg into const double t ( we used arg[0] as arg[1] is mathematical part of p functions as they also match the regex
}
return func; // return updated
});
console.log(replaced) // for debug purpose
return replaced.join("*/\n"); // join replaced string to get full string
}
const news = convertJstoC();
fs.writeFileSync('erfcx_chebyshev.c', news); // save it to another file from where we can copy it to main codebase created this script to convert all p0 to p100 functions from JavaScript to C as well as update doc to follow C-Deoxygen format and rest of the code was written manually I have not added this script on pr as this didnt seem important hence added it in comment as an insight screenshot for outputedit: Updated Script to match stdlib conventions as well as updated screenshot output to show visual output |
updated all missed @\returns to @\return now this pr is ready for review |
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/c/native/benchmark.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/math/base/special/erfcx/examples/c/example.c
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/math/base/special/erfcx/include/stdlib/math/base/special/erfcx.h
Outdated
Show resolved
Hide resolved
Signed-off-by: Athan <kgryte@gmail.com>
Signed-off-by: Athan <kgryte@gmail.com>
lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js
Outdated
Show resolved
Hide resolved
@kgryte updated all the suggested changes, as well as updated script in the comment and now it should follow the convention: also updated screenshot for a visual output |
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.
left a few comments, thanks for working on this!
lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/benchmark.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/c/native/Makefile
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/benchmark.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/benchmark/benchmark.native.js
Outdated
Show resolved
Hide resolved
lib/node_modules/@stdlib/math/base/special/erfcx/test/test.native.js
Outdated
Show resolved
Hide resolved
@gunjjoshi You should now have permissions to take over this PR and directly edit/commit. LMK if not. |
…ative/benchmark.c Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
…ative/benchmark.c Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
…chmark.native.js Signed-off-by: Gunj Joshi <gunjjoshi8372@gmail.com>
Made some changes, should be good to go! |
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.
Didn't notice anything off during code review.
Thanks to @USERSATOSHI for creating the PR and @gunjjoshi for getting it over the finish line!
Signed-off-by: Philipp Burckhardt <pburckhardt@outlook.com>
Description
This pull request:
@stdlib/math/base/special/erfcx
Related Issues
This pull request:
@stdlib/math/base/special/erfcx
#1949Questions
No.
Other
No.
Checklist
@stdlib-js/reviewers