OrangeC icon indicating copy to clipboard operation
OrangeC copied to clipboard

Absent functions in math library

Open alvoskov opened this issue 1 year ago • 4 comments

The mathematical library doesn't contain such functions as erf or lgamma (they are required by C99 standard). E.g. such program doesn't compile. The functions prototypes are present in the header files but are not implemented.

#include "stdio.h"
#include "math.h"

int main()
{
    printf("%g\n", exp(1.0));
    printf("%g\n", exp(lgamma(4.0)));
} 

occ /9 a.c

Error: Undefined External 'lgamma' in module a.c

alvoskov avatar Nov 12 '24 12:11 alvoskov

yeah i was lazy about lgamma.... the last math implementation I got didn't have it and I never looked for a replacement. Will see what I can do....

LADSoft avatar Nov 26 '24 22:11 LADSoft

So, I've made my 2fa stuff using some TOTP tools. Anyways: There's plenty of functions that aren't implemented atm, e.g. the aforementioned erf (Oh hey, someone's implementation based off of a big book of these tables! https://www.johndcook.com/cpp_erf.html ) C23 has a few of these as well, e.g. the <trigfunc>pi functions, which is mildly different in implementation (if we want the highest accuracy) from the regular <trigfunc>. This is probably going to be really annoying to implement all of these mathematical functions, but we should do it anyways.

chuggafan avatar Dec 13 '24 04:12 chuggafan

glad you are back on :smile:

So probably the best thing to do is pull the function from llvm/libc implementation (which is here on github).... probably take a little bit of refactoring though....

LADSoft avatar Dec 13 '24 15:12 LADSoft

I've taken a quick gander over at the llvm libc area.... it would require a lot of refactoring I believe... I also don't believe they have the <something>pi functions, which glibc has. Glibc DOES seem to be implementing those <something>pi functions in a straightforward way however, and we could do the same thing, we just need to identify what we're missing in order to fill in everything.

chuggafan avatar Dec 14 '24 00:12 chuggafan