Compiled functions: branching in FastExpression, and compiled forms for the newer nodes
Los mantenedores suelen responder en 1 día
Nadie ha tomado este issue todavía.
Evaluación
- Dificultad
- 5/5
- Tiempo estimado
- Más de una semana
- Aptitud para principiantes
- 45/100
Línea de trabajo
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.
Escrito por el modelo de indexación a partir del texto del issue.
Descripción
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.
- Lenguaje dominante
- C#
- Estrellas
- 831
- Forks
- 79
- Merge medio
- 1 h 14 min
- PR fusionados (30 d)
- 522
Preparar el entorno
- Sin Dockerfile ni archivo de Docker Compose
- Sin plantilla de pull request
- Leer la guía de contribución
Primeros pasos
- Lee el issue completo y luego la guía de contribución del proyecto.
- Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
- Haz un fork del repositorio y trabaja en una rama.
- Abre un pull request que haga referencia al número del issue.
Más de ASC-Community/AngouriMath
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
ASC-Community/AngouriMath#2182 · 16 comentarios ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
ASC-Community/AngouriMath#2164 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
ASC-Community/AngouriMath#2160 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 4/5 3-5 días Aptitud para principiantes 48/100
ASC-Community/AngouriMath#2153 ·
Los mantenedores suelen responder en 1 día
-
Dificultad 5/5 Más de una semana Aptitud para principiantes 35/100
ASC-Community/AngouriMath#2152 ·
Los mantenedores suelen responder en 1 día
Todos los issues de ASC-Community/AngouriMath
Issues similares
-
Add dependency list in documentsAbierto
Dificultad 2/5 1-3 horas Aptitud para principiantes 67/100
Los mantenedores suelen responder en 3 días
-
Add 'upm' tag on githubAbierto
Dificultad 1/5 Menos de una hora Aptitud para principiantes 85/100
-
Dificultad 2/5 1-3 horas Aptitud para principiantes 76/100
Los mantenedores suelen responder en 1 día
-
bug mac アプリ: コード アプリ: チャット 優先: 中 要トリアージ
Dificultad 2/5 1-3 horas Aptitud para principiantes 74/100
yksr-melt/Meltype#1346 · 2 comentarios ·
Los mantenedores suelen responder en 1 día
-
Collect corrected translations in the app, with no GitHub account and the least possible frictionAbiertolocalization medium ui
Dificultad 2/5 1-3 horas Aptitud para principiantes 65/100
hexide-io/HexIDE#2819 · 1 comentario ·
Los mantenedores suelen responder en 1 día