Hacktoberfest 2026: los issues que los mantenedores marcaron para octubre, abiertos y aptos para principiantes. Explorar issues de Hacktoberfest

Compiled functions: branching in FastExpression, and compiled forms for the newer nodes

Abierto
#2,195 2 comentarios 0 reacciones 0 asignados Ver en GitHub

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
Tipo de issue
Nueva funcionalidad
Claridad
Bastante claro
Estado de actividad
Activo
Stack tecnológico
csharp
Área
backend

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:

  1. FastExpression has no booleans and no branch. So piecewise, provided, iverson and 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 single foreach, so a jump would also need an indexed loop. A comparison of a value that is not real should come out false, so that x provided x > 0 is NaN at i, as EvalNumerical has it.
  2. LINQ over Complex refuses comparisons. The message is The binary operator GreaterThan is not defined for the types 'System.Numerics.Complex'. So piecewise and provided compile over double but not over Complex, and mod fails 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.
  3. These nodes have no compiled form in either compiler:
    • conj, arg, Re and Im: one System.Numerics.Complex call each.
    • iverson: a conditional in LINQ.
    • binomial, fallingfactorial, risingfactorial, n!!, gamma(a, z) and polygamma: these need numerical implementations over double and Complex.
    • The integer functions prime, valuation, gcd, lcm, mobius, divisorsigma, primenu, primeomega, primepi and divides, and membership x in [0; 1]. These could compile over double at whole numbers and give NaN elsewhere, or stay refused.
  4. The calculus nodes and binders are refused by both: derivative, the definite integral, limit, sum, product and apply(lambda(…)). Compiling expr.Evaled first gives the computed form. Whether Compile should 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

Primeros pasos

  1. Lee el issue completo y luego la guía de contribución del proyecto.
  2. Comenta en el issue que vas a ocuparte — evita que dos personas hagan lo mismo.
  3. Haz un fork del repositorio y trabaja en una rama.
  4. Abre un pull request que haga referencia al número del issue.

Más de ASC-Community/AngouriMath

Todos los issues de ASC-Community/AngouriMath

Issues similares

Más issues de C#

Recibe los nuevos issues en tu correo

Un resumen breve de issues de GitHub para principiantes.