Compiled functions: branching in FastExpression, and compiled forms for the newer nodes
Maintainer antworten meist innerhalb von 1 Tag
Dieses Issue hat noch niemand übernommen.
Bewertung
- Schwierigkeit
- 5/5
- Geschätzter Aufwand
- Über eine Woche
- Anfängerfreundlichkeit
- 45/100
Rechercherichtung
Start by reading the compilecheck harness described in the issue and the two compiler implementations, FastExpression and LINQ; the payload does not give their file paths. Compare their handling of the refused nodes and tests, especially branching, Complex comparisons, and newer nodes. The scope includes design decisions around jumps and whether compilation should evaluate calculus nodes first; done means adding compiled support for selected gaps with results consistent with EvalNumerical.
Vom Indexierungsmodell aus dem Issue-Text verfasst.
Beschreibung
A harness, compilecheck, compiles a sample of every node that has a numeric or boolean value through both compilers, calls it at sample points, and compares the result with Substitute then EvalNumerical. Measured on master ea0821442. Every compiled value agrees with EvalNumerical. What is missing are nodes that are refused.
| compiler | compiles |
|---|---|
FastExpression, Compile("x") |
43 of 71 numeric nodes, and 0 of 12 boolean |
LINQ, Compile<Complex, Complex> |
42 of 71 |
LINQ, Compile<double, double> |
44 of 71 |
LINQ, Compile<double, bool> |
10 of 12 boolean |
What is missing, grouped by what it would take:
- FastExpression has no booleans and no branch. So
piecewise,provided,iversonand every comparison are refused. The fix needs comparison and connective instructions that push 1 or 0, and a select instruction. The instructions run in a singleforeach, so a jump would also need an indexed loop. A comparison of a value that is not real should come out false, so thatx provided x > 0is NaN ati, asEvalNumericalhas it. - LINQ over
Complexrefuses comparisons. The message isThe binary operator GreaterThan is not defined for the types 'System.Numerics.Complex'. Sopiecewiseandprovidedcompile overdoublebut not overComplex, andmodfails the same way. A fix would compile a comparison of complex operands as a comparison of real parts when both operands are real, and as false otherwise. - These nodes have no compiled form in either compiler:
conj,arg,ReandIm: oneSystem.Numerics.Complexcall each.iverson: a conditional in LINQ.binomial,fallingfactorial,risingfactorial,n!!,gamma(a, z)andpolygamma: these need numerical implementations overdoubleandComplex.- The integer functions
prime,valuation,gcd,lcm,mobius,divisorsigma,primenu,primeomega,primepianddivides, and membershipx in [0; 1]. These could compile overdoubleat whole numbers and give NaN elsewhere, or stay refused.
- The calculus nodes and binders are refused by both:
derivative, the definiteintegral,limit,sum,productandapply(lambda(…)). Compilingexpr.Evaledfirst gives the computed form. WhetherCompileshould do that itself is a decision, because it would make compiling as slow as evaluating.
The full table
| node | sample | FastExpression | LINQ Complex |
LINQ double |
|---|---|---|---|---|
Variable |
x |
ok | ok | ok |
Integer |
3 |
ok | ok | ok |
Rational |
1/2 |
ok | ok | ok |
Real (root is Rational) |
0.5 |
ok | ok | ok |
Complex (root is Sumf) |
2 + 3i |
ok | ok | refused |
Constant |
pi |
ok | ok | ok |
Sumf |
x + 3 |
ok | ok | ok |
Minusf |
x - (x^2) |
ok | ok | ok |
Mulf |
x * (x + 1) |
ok | ok | ok |
Divf |
x / (x + 2) |
ok | ok | ok |
Powf |
x ^ 3 |
ok | ok | ok |
Logf |
log(2, x) |
ok | ok | ok |
Sinf |
sin(x) |
ok | ok | ok |
Cosf |
cos(x) |
ok | ok | ok |
Tanf |
tan(x) |
ok | ok | ok |
Cotanf |
cotan(x) |
ok | ok | ok |
Secantf |
sec(x) |
ok | ok | ok |
Cosecantf |
cosec(x) |
ok | ok | ok |
Arcsinf |
arcsin(x) |
ok | ok | ok |
Arccosf |
arccos(x) |
ok | ok | ok |
Arctanf |
arctan(x) |
ok | ok | ok |
Arccotanf |
arccotan(x) |
ok | ok | ok |
Arcsecantf |
arcsec(x) |
ok | ok | ok |
Arccosecantf |
arccosec(x) |
ok | ok | ok |
Absf |
abs(x) |
ok | ok | ok |
Signumf |
sgn(x) |
ok | ok | ok |
Conjugatef |
conj(x) |
refused | refused | refused |
Argf |
arg(x) |
refused | refused | refused |
Ref |
Re(x) |
refused | refused | refused |
Imf |
Im(x) |
refused | refused | refused |
Floorf |
floor(x) |
ok | ok | ok |
Ceilf |
ceil(x) |
ok | ok | ok |
Roundf |
round(x) |
ok | ok | ok |
Modf |
x mod 3 |
ok | refused | ok |
Maxf |
max(x, 1) |
ok | ok | ok |
Minf |
min(x, 1) |
ok | ok | ok |
Factorialf |
x! |
ok | ok | ok |
DoubleFactorialf |
x!! |
refused | refused | refused |
Binomialf |
binomial(x, 3) |
refused | refused | refused |
FallingFactorialf |
fallingfactorial(x, 3) |
refused | refused | refused |
RisingFactorialf |
risingfactorial(x, 3) |
refused | refused | refused |
IncompleteGammaf |
gamma(2, x) |
refused | refused | refused |
Polygammaf |
polygamma(1, x) |
refused | refused | refused |
Erff |
erf(x) |
ok | ok | ok |
Erfcf |
erfc(x) |
ok | ok | ok |
Erfif |
erfi(x) |
ok | ok | ok |
Eif |
Ei(x) |
ok | ok | ok |
Lif |
li(x) |
ok | ok | ok |
Sif |
Si(x) |
ok | ok | ok |
Cif |
Ci(x) |
ok | ok | ok |
Shif |
Shi(x) |
ok | ok | ok |
Chif |
Chi(x) |
ok | ok | ok |
Phif |
phi(x) |
ok | ok | ok |
Primef |
prime(x) |
refused | refused | refused |
Valuationf |
valuation(x, 2) |
refused | refused | refused |
Gcdf |
gcd(x, 4) |
refused | refused | refused |
Lcmf |
lcm(x, 4) |
refused | refused | refused |
Mobiusf |
mobius(x) |
refused | refused | refused |
DivisorSigmaf |
divisorsigma(1, x) |
refused | refused | refused |
PrimeNuf |
primenu(x) |
refused | refused | refused |
PrimeOmegaf |
primeomega(x) |
refused | refused | refused |
PrimePif |
primepi(x) |
refused | refused | refused |
Iversonf |
iverson(x > 0) |
refused | refused | refused |
Providedf |
x provided x > 0 |
refused | refused | ok |
Piecewise |
piecewise(x provided x > 0, -x provided x <= 0) |
refused | refused | ok |
Derivativef |
derivative(x^3, x) |
refused | refused | refused |
Integralf |
integral(t x, t, 0, 1) |
refused | refused | refused |
Limitf |
limit(sin(t x)/t, t, 0) |
refused | refused | refused |
Summationf |
sum(k x, k, 1, 3) |
refused | refused | refused |
Productf |
product(x + k, k, 1, 3) |
refused | refused | refused |
Application |
apply(lambda(t, t^2), x) |
refused | refused | refused |
| node | sample | FastExpression | LINQ double -> bool |
|---|---|---|---|
Equalsf |
x = 2.5 |
refused | ok |
Greaterf |
x > 1 |
refused | ok |
GreaterOrEqualf |
x >= 1 |
refused | ok |
Lessf |
x < 1 |
refused | ok |
LessOrEqualf |
x <= 1 |
refused | ok |
Andf |
x > 0 and x < 2 |
refused | ok |
Orf |
x < 0 or x > 2 |
refused | ok |
Xorf |
x > 0 xor x > 1 |
refused | ok |
Notf |
not x > 0 |
refused | ok |
Impliesf |
x > 0 -> x > 1 |
refused | ok |
Dividesf |
3 divides x |
refused | refused |
Inf |
x in [0; 1] |
refused | refused |
Related: #2145 and #2182, which added most of the nodes in item 3.
- Vorherrschende Sprache
- C#
- Sterne
- 831
- Forks
- 79
- Ø Merge
- 1 Std. 14 Min.
- Gemergte PRs (30 T.)
- 522
Entwicklungsumgebung
- Kein Dockerfile und keine Docker-Compose-Datei
- Keine Pull-Request-Vorlage
- Beitragsleitfaden lesen
Erste Schritte
- Lesen Sie das ganze Issue und danach den Beitragsleitfaden des Projekts.
- Schreiben Sie ins Issue, dass Sie es übernehmen — das erspart doppelte Arbeit.
- Forken Sie das Repository und arbeiten Sie in einem Branch.
- Öffnen Sie einen Pull Request, der die Issue-Nummer nennt.
Mehr aus ASC-Community/AngouriMath
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
ASC-Community/AngouriMath#2182 · 16 Kommentare ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
ASC-Community/AngouriMath#2164 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
ASC-Community/AngouriMath#2160 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 4/5 3-5 Tage Anfängerfreundlichkeit 48/100
ASC-Community/AngouriMath#2153 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 5/5 Über eine Woche Anfängerfreundlichkeit 35/100
ASC-Community/AngouriMath#2152 ·
Maintainer antworten meist innerhalb von 1 Tag
Alle Issues in ASC-Community/AngouriMath
Ähnliche Issues
-
bug effort:S P3
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 85/100
nightscout/nocturne#3093 ·
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 67/100
Maintainer antworten meist innerhalb von 3 Tagen
-
Add 'upm' tag on githubOffen
Schwierigkeit 1/5 Unter einer Stunde Anfängerfreundlichkeit 85/100
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100
Maintainer antworten meist innerhalb von 1 Tag
-
Schwierigkeit 2/5 1-3 Stunden Anfängerfreundlichkeit 76/100