-
Notifications
You must be signed in to change notification settings - Fork 110
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
math: p_erf: Implement error function #198
base: master
Are you sure you want to change the base?
Conversation
To calculate error function
Hi! You need to provide an actual implementation of the function, not just a wrapper using |
Okay. |
* | ||
*/ | ||
#include <math.h> | ||
void p_erff_f32(const float *a, float *c, int n) |
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.
In my opinion, name can be changed to p_erf_f32
.
In math.h
it's named erff
since it operates on float
. In pal types are specified as a suffix (eg. _u64
, _f32
), so the additional f
can be omitted.
Thanks for creative comments. I will look into that. |
Hi @Adamszk, I think that's a good idea. If you would like to use a polynomial approximation, you can find one here: http://eliteraspberries.github.io/pal/formulas/#erf |
to eliteraspberries and mateunho, thanks for comments. I looked at the formula and tested it. It does not give me a sixth decimal precision when comparing to standard erf(x) function. I think it is required for float numbers. On top of that, it has to depend on exp(x) function and I do not know how it will effect the erf(x) when exp() is modified. I am trying to write a standalone erf(x). I have been looking for fast erf algorithm with 6th decimal precision and I found one however, it still relies on exp(x). Using standard exp(x) I tested that my_erf(x) and it works works fine, but when I tried to implement my_exp(x), the precision is reduced to two decimals for one algorithm and 4 decimals to other algorithm. I just need more time to find exp(x) and implement my_erf(x) for parallella purpose and test it before I submit it. erf(x) is very sensitive to exp(x) function. |
@Adamszk, 6 decimal digits is the best accuracy for the |
@eliteraspberries , finally I did find the exp(x) function that works for me that gives my erf(x) precision to 6 decimals. All is left is to do a lot of pruning (I was adding and testing a lot of codes in one file) and then adapt it to parallella. Then test it with pal etc. I hope it will work fine. it is about 5 times faster than math.h erf function. |
@mateunho , yes, erf(x) is the unary function. I just copy the data and modified the output. I don't know the purpose of the second column. I assume it is a second input. If it is, then when updating, I will set the second column to zero's. What is the allowed maximum rows in data file? Is the number of rows the same for all functions? |
@Adamszk Test data file structure consists of following columns (all of them are required):
so in case of |
@Adamszk Debugging would be easier if you pushed recent changes to the github :)
|
I dont believe it is complete. I have to double check it with larger data file (more data lines). My first code was working fine with the old data file but when used more data lines to about 100, few numbers did not match. I gave up that code with a new one from scratch. It is much simpler but slower for larger numbers of a. I tested that code with old data lines of 32. Later I will retest it with more data lines of up to 100. Please see the issue with file.dat update. Any comments and constructive criticisms are welcome. |
👍 Very accurate output, and at least 10 times faster than GNU libm on x86. |
I have only one suggestion: to generate new test data, for input in [-3, 3]. For example, with Python:
|
@eliteraspberries |
@olajep |
@Adamszk, I would suggest
|
@mateunho Thanks. rebase/squash commits will take some time. Like I said before, I am new to Git. |
Added erff.c data file error function data file for testing Added erff.c function Added erff.c function Added erff.c function Removing erff(x) and adding erf(x) Removing erff(x) and adding erf(x) Removing erff(x) and adding erf(x) parallella code Removing erff(x) and adding erf(x) Update Makefile.am Update p_erff_f32.dat Removing erff(x) and adding erf(x) Rename p_erff_f32.dat to p_erf_f32.dat Update p_erf_f32.dat Update Makefile.am Update Makefile.am Rename p_erff.c to p_erf.c Update Makefile.am Update Makefile.am Update Makefile.am Update Makefile.am math: p_erf: Implement error function math: p_erf: Implement error function update erf.c Developer Certificate of Origin Version 1.1 Copyright (C) 2004, 2006 The Linux Foundation and its contributors. 660 York Street, Suite 102, San Francisco, CA 94110 USA Everyone is permitted to copy and distribute verbatim copies of this license document, but changing it is not allowed. Developer's Certificate of Origin 1.1 By making a contribution to this project, I certify that: (a) The contribution was created in whole or in part by me and I have the right to submit it under the open source license indicated in the file; or (b) The contribution is based upon previous work that, to the best of my knowledge, is covered under an appropriate open source license and I have the right under that license to submit that work with modifications, whether created in whole or in part by me, under the same open source license (unless I am permitted to submit under a different license), as indicated in the file; or (c) The contribution was provided directly to me by some other person who certified (a), (b) or (c) and I have not modified it. (d) I understand and agree that this project and the contribution are public and that a record of the contribution (including all personal information I submit with it, including my sign-off) is maintained indefinitely and may be redistributed consistent with this project or the open source license(s) involved. Signed-off-by: Adam Szewczyk <[email protected]>
@mateunho I am done with squashing and correcting the sign off. I hope that's everything and correctly. Again, thanks to all for support. Adieu. |
@eliteraspberries |
One fork is perfectly fine. The thing you need is another branch.
After that you'll get a brand new branch synced with current state of PAL. |
what do I put in upstream/master ? |
@Adamszk
hence |
@mateunho |
@Adamszk As a software engineer I'm used to using many branches for development purposes, master being the one for syncing with stable release. If you're interested in deeper insight into working with branches take a look at this and that. If you want your PR to get merged quicker, ask @aolofsson or @olajep for review. Regards, |
@olajep |
@mateunho , So which branch I am supposed to do a new code adding. Pal3/devel or Pal3/Master The devel branch does not have erf(x) I created. Should I restart the erf(x) commit? |
@Adamszk, if you want your code additions to be considered as a separate features, then commit them on different branches. Unless your new code is dependent on
|
I am adding math function to math library. Tested on stand alone location of parallella. it works fine. Please ignore my spelling error on comments in commits. The actual codes spelling are correct. Please notify me of any errors or improvement opportunities in Git set up. I am a new Git user. Thank you.