•math.Erf, •math.ErfC, and •math.LogFact
This commit is contained in:
parent
9a1268ea3a
commit
35aef1e5cd
@ -17,7 +17,7 @@
|
||||
/*internal.c*/M(itype,"•internal.Type") M(elType,"•internal.ElType") M(refc,"•internal.Refc") M(isPure,"•internal.IsPure") A(info,"•internal.Info") M(heapDump,"•internal.HeapDump") \
|
||||
/*internal.c*/M(squeeze,"•internal.Squeeze") M(deepSqueeze,"•internal.DeepSqueeze") D(eequal,"•internal.EEqual") A(internalTemp,"•internal.Temp") \
|
||||
/*internal.c*/D(variation,"•internal.Variation") A(listVariations,"•internal.ListVariations") M(clearRefs,"•internal.ClearRefs") M(unshare,"•internal.Unshare") \
|
||||
/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") D(atan2,"•math.Atan2") D(hypot,"•math.Hypot") M(sinh,"•math.Sinh") M(cosh,"•math.Cosh") M(tanh,"•math.Tanh") M(asinh,"•math.Asinh") M(acosh,"•math.Acosh") M(atanh,"•math.Atanh") M(cbrt,"•math.Cbrt") M(log2,"•math.Log2") M(log10,"•math.Log10") M(log1p,"•math.Log1p") M(expm1,"•math.Expm1") M(fact,"•math.Fact") D(comb,"•math.Comb") D(gcd,"•math.GCD") D(lcm,"•math.LCM")
|
||||
/* arithm.c*/M(sin,"•math.Sin") M(cos,"•math.Cos") M(tan,"•math.Tan") M(asin,"•math.Asin") M(acos,"•math.Acos") M(atan,"•math.Atan") D(atan2,"•math.Atan2") D(hypot,"•math.Hypot") M(sinh,"•math.Sinh") M(cosh,"•math.Cosh") M(tanh,"•math.Tanh") M(asinh,"•math.Asinh") M(acosh,"•math.Acosh") M(atanh,"•math.Atanh") M(cbrt,"•math.Cbrt") M(log2,"•math.Log2") M(log10,"•math.Log10") M(log1p,"•math.Log1p") M(expm1,"•math.Expm1") M(fact,"•math.Fact") D(comb,"•math.Comb") M(logfact,"•math.LogFact") M(erf,"•math.Erf") M(erfc,"•math.ErfC") D(gcd,"•math.GCD") D(lcm,"•math.LCM")
|
||||
|
||||
#define FOR_PM1(A,M,D) \
|
||||
/*md1.c*/A(tbl,"⌜") A(each,"¨") A(fold,"´") A(scan,"`") A(const,"˙") A(swap,"˜") A(cell,"˘") A(insert,"˝") \
|
||||
|
||||
@ -88,14 +88,16 @@ GC1f( div, 1/xv, "÷: Getting reciprocal of non-number")
|
||||
GC1f(root, sqrt(xv), "√: Getting square root of non-number")
|
||||
#undef GC1f
|
||||
|
||||
f64 fact(f64 x) { return tgamma(x+1); }
|
||||
f64 fact(f64 x) { return tgamma(x+1); }
|
||||
f64 logfact(f64 x) { return lgamma(x+1); }
|
||||
|
||||
#define P1(N) { if(isArr(x)) { SLOW1("arithm " #N, x); return arith_recm(N##_c1, x); } }
|
||||
B pow_c1(B t, B x) { if (isF64(x)) return m_f64( exp(x.f)); P1( pow); thrM("⋆: Getting exp of non-number"); }
|
||||
B log_c1(B t, B x) { if (isF64(x)) return m_f64( log(x.f)); P1( log); thrM("⋆⁼: Getting log of non-number"); }
|
||||
#define MATH(n,N) \
|
||||
B n##_c1(B t, B x) { if (isF64(x)) return m_f64(n(x.f)); P1(n); thrM("•math." #N ": Argument contained non-number"); }
|
||||
MATH(cbrt,Cbrt) MATH(log2,Log2) MATH(log10,Log10) MATH(log1p,Log1p) MATH(expm1,Expm1) MATH(fact,Fact)
|
||||
MATH(cbrt,Cbrt) MATH(log2,Log2) MATH(log10,Log10) MATH(log1p,Log1p) MATH(expm1,Expm1)
|
||||
MATH(fact,Fact) MATH(logfact,LogFact) MATH(erf,Erf) MATH(erfc,ErfC)
|
||||
#define TRIG(n,N) MATH(n,N) MATH(a##n,A##n) MATH(n##h,N##h) MATH(a##n##h,A##n##h)
|
||||
TRIG(sin,Sin) TRIG(cos,Cos) TRIG(tan,Tan)
|
||||
#undef TRIG
|
||||
@ -111,8 +113,8 @@ static B mathNS;
|
||||
B getMathNS() {
|
||||
if (mathNS.u == 0) {
|
||||
#define F(X) inc(bi_##X),
|
||||
Body* d = m_nnsDesc("sin","cos","tan","asin","acos","atan","atan2","sinh","cosh","tanh","asinh","acosh","atanh","cbrt","log2","log10","log1p","expm1","hypot","fact","comb","gcd","lcm");
|
||||
mathNS = m_nns(d, F(sin)F(cos)F(tan)F(asin)F(acos)F(atan)F(atan2)F(sinh)F(cosh)F(tanh)F(asinh)F(acosh)F(atanh)F(cbrt)F(log2)F(log10)F(log1p)F(expm1)F(hypot)F(fact)F(comb)F(gcd)F(lcm));
|
||||
Body* d = m_nnsDesc("sin","cos","tan","asin","acos","atan","atan2","sinh","cosh","tanh","asinh","acosh","atanh","cbrt","log2","log10","log1p","expm1","hypot","fact","logfact","erf","erfc","comb","gcd","lcm");
|
||||
mathNS = m_nns(d, F(sin)F(cos)F(tan)F(asin)F(acos)F(atan)F(atan2)F(sinh)F(cosh)F(tanh)F(asinh)F(acosh)F(atanh)F(cbrt)F(log2)F(log10)F(log1p)F(expm1)F(hypot)F(fact)F(logfact)F(erf)F(erfc)F(comb)F(gcd)F(lcm));
|
||||
#undef F
|
||||
gc_add(mathNS);
|
||||
}
|
||||
@ -124,20 +126,17 @@ void arith_init() {
|
||||
c(BFn,bi_mul)->ident = c(BFn,bi_div)->ident = c(BFn,bi_and)->ident = c(BFn,bi_eq)->ident = c(BFn,bi_ge)->ident = c(BFn,bi_pow)->ident = c(BFn,bi_not)->ident = m_i32(1);
|
||||
c(BFn,bi_floor)->ident = m_f64(1.0/0.0);
|
||||
c(BFn,bi_ceil )->ident = m_f64(-1.0/0.0);
|
||||
|
||||
|
||||
#define INVERSE_PAIR(F,G) \
|
||||
c(BFn,bi_##F)->im = G##_c1; \
|
||||
c(BFn,bi_##G)->im = F##_c1;
|
||||
c(BFn,bi_sub)->im = sub_c1;
|
||||
c(BFn,bi_sin)->im = asin_c1;
|
||||
c(BFn,bi_cos)->im = acos_c1;
|
||||
c(BFn,bi_tan)->im = atan_c1;
|
||||
c(BFn,bi_asin)->im = sin_c1;
|
||||
c(BFn,bi_acos)->im = cos_c1;
|
||||
c(BFn,bi_atan)->im = tan_c1;
|
||||
c(BFn,bi_sinh)->im = asinh_c1;
|
||||
c(BFn,bi_cosh)->im = acosh_c1;
|
||||
c(BFn,bi_tanh)->im = atanh_c1;
|
||||
c(BFn,bi_asinh)->im = sinh_c1;
|
||||
c(BFn,bi_acosh)->im = cosh_c1;
|
||||
c(BFn,bi_atanh)->im = tanh_c1;
|
||||
c(BFn,bi_expm1)->im = log1p_c1;
|
||||
c(BFn,bi_log1p)->im = expm1_c1;
|
||||
INVERSE_PAIR(sin, asin)
|
||||
INVERSE_PAIR(cos, acos)
|
||||
INVERSE_PAIR(tan, atan)
|
||||
INVERSE_PAIR(sinh, asinh)
|
||||
INVERSE_PAIR(cosh, acosh)
|
||||
INVERSE_PAIR(tanh, atanh)
|
||||
INVERSE_PAIR(expm1, log1p)
|
||||
#undef INVERSE_PAIR
|
||||
}
|
||||
|
||||
@ -1551,7 +1551,7 @@ u32* dsv_text[] = {
|
||||
U"•file.MapBytes",U"•file.Modified",U"•file.Name",U"•file.Parent",U"•file.Remove",U"•file.Rename",U"•file.Size",U"•file.Type",
|
||||
|
||||
U"•internal.ClearRefs",U"•internal.DeepSqueeze",U"•internal.EEqual",U"•internal.ElType",U"•internal.HeapDump",U"•internal.Info",U"•internal.IsPure",U"•internal.ListVariations",U"•internal.Refc",U"•internal.Squeeze",U"•internal.Temp",U"•internal.Type",U"•internal.Unshare",U"•internal.Variation",
|
||||
U"•math.Acos",U"•math.Acosh",U"•math.Asin",U"•math.Asinh",U"•math.Atan",U"•math.Atan2",U"•math.Atanh",U"•math.Cbrt",U"•math.Comb",U"•math.Cos",U"•math.Cosh",U"•math.Expm1",U"•math.Fact",U"•math.GCD",U"•math.Hypot",U"•math.LCM",U"•math.Log10",U"•math.Log1p",U"•math.Log2",U"•math.Sin",U"•math.Sinh",U"•math.Tan",U"•math.Tanh",
|
||||
U"•math.Acos",U"•math.Acosh",U"•math.Asin",U"•math.Asinh",U"•math.Atan",U"•math.Atan2",U"•math.Atanh",U"•math.Cbrt",U"•math.Comb",U"•math.Cos",U"•math.Cosh",U"•math.Erf",U"•math.ErfC",U"•math.Expm1",U"•math.Fact",U"•math.GCD",U"•math.Hypot",U"•math.LCM",U"•math.Log10",U"•math.Log1p",U"•math.Log2",U"•math.LogFact",U"•math.Sin",U"•math.Sinh",U"•math.Tan",U"•math.Tanh",
|
||||
U"•rand.Deal",U"•rand.Range",U"•rand.Subset",
|
||||
U"•term.CharB",U"•term.CharN",U"•term.ErrRaw",U"•term.Flush",U"•term.OutRaw",U"•term.RawMode",
|
||||
NULL
|
||||
|
||||
Loading…
Reference in New Issue
Block a user