crowlogic / arb4j

arb4j is a Java API for the arbitrary precision ball arithmetic library found at http://arblib.org
Other
1 stars 0 forks source link

expression compiler: rectify the namespace collision resulting from nested subexpressions sharing the same context #349

Closed crowlogic closed 6 months ago

crowlogic commented 6 months ago

the

    factorFunctionFieldName = expression.getNextIntermediateVariableFieldName("factor", resultType);

functionality needs to be moved to the Context instead of the variable since these variables share the Context not the expressions other than in the sense of being linked via the parentExpression reference and a mutual Context

crowlogic commented 6 months ago

Generating z➔Σn➔z^n*∏k➔α[k]₍ₙ₎{k=1…p}/n!*∏k➔β[k]₍ₙ₎{k=1…q}{n=0…N}
class arb.expressions.nodes.nary.Sum.assignFieldNames(resultType=class arb.Real) factorFunctionFieldName=factorℝ1 factorValueFieldName=valueℝ1
Sum: generateFactorClass( expr=n➔z^n*∏k➔α[k]₍ₙ₎{k=1…p}/n!*∏k➔β[k]₍ₙ₎{k=1…q},resultType=class arb.Real)
Generating n➔z^n*∏k➔α[k]₍ₙ₎{k=1…p}/n!*∏k➔β[k]₍ₙ₎{k=1…q}
BinaryOperation.generate( this=BinaryOperation[left=\frac{{{z}^{n}} \cdot {\prod_{k = 1}^{p}{α[k]₍ₙ₎}}}{(n)!}, right=\prod_{k = 1}^{q}{β[k]₍ₙ₎}, operation=mul, generatedType=null], resultType=class arb.Real )

BinaryOperation.generate( this=BinaryOperation[left={{z}^{n}} \cdot {\prod_{k = 1}^{p}{α[k]₍ₙ₎}}, right=(n)!, operation=div, generatedType=null], resultType=class arb.Real )

BinaryOperation.generate( this=BinaryOperation[left={z}^{n}, right=\prod_{k = 1}^{p}{α[k]₍ₙ₎}, operation=mul, generatedType=null], resultType=class arb.Real )

BinaryOperation.generate( this=BinaryOperation[left=z, right=n, operation=pow, generatedType=null], resultType=class arb.Integer )

class arb.expressions.nodes.nary.Product.assignFieldNames(resultType=class arb.Real) factorFunctionFieldName=factorℝ2 factorValueFieldName=valueℝ2
Product: generateFactorClass( expr=k➔α[k]₍ₙ₎,resultType=class arb.Real)
Generating k➔α[k]₍ₙ₎
BinaryOperation.generate( this=BinaryOperation[left=α_{k}, right=n, operation=risingFactorial, generatedType=null], resultType=class arb.Real )

FunctionCall.generate: this=FunctionCall[name=factorial, arg=n, targetResultType=arb.Real] resultType=class arb.Integer
class arb.expressions.nodes.nary.Product.assignFieldNames(resultType=class arb.Real) factorFunctionFieldName=factorℝ3 factorValueFieldName=valueℝ3
Product: generateFactorClass( expr=k➔β[k]₍ₙ₎,resultType=class arb.Real)
Generating k➔β[k]₍ₙ₎
BinaryOperation.generate( this=BinaryOperation[left=β_{k}, right=n, operation=risingFactorial, generatedType=null], resultType=class arb.Real )

Exception in thread "main" java.lang.VerifyError: Bad type on operand stack
Exception Details:
  Location:
    factorℝ1.evaluate(Ljava/lang/Object;IILjava/lang/Object;)Ljava/lang/Object; @150: invokevirtual
  Reason:
    Type 'arb/Real' (current frame, stack[3]) is not assignable to 'arb/Integer'
  Current Frame:
    bci: @150
    flags: { }
    locals: { 'factorℝ1', 'java/lang/Object', integer, integer, 'java/lang/Object' }
    stack: { 'arb/Real', 'java/lang/Object', 'arb/Integer', 'arb/Real' }
  Bytecode:
    0000000: 2ab4 000e 9a00 072a b600 122a b400 162b
    0000010: c000 181d 2ab4 001b b600 1f2a b400 232b
    0000020: c000 18b5 0027 2ab4 002b b600 3157 2ab4
    0000030: 0034 2ab4 0037 b600 3b57 2ab4 003e 2ab4
    0000040: 0041 b600 3b57 2ab4 002b 2ab4 0023 2ab4
    0000050: 0034 1d2a b400 44b9 0047 0400 c000 2d1d
    0000060: b600 4b57 2ab4 0034 b600 4f2a b400 3eb6
    0000070: 0053 9eff d42a b400 2b1d 2ab4 0056 b600
    0000080: 5919 042b c000 181d 2ab4 005c b600 602a
    0000090: b400 63c0 002d b600 661d 2ab4 0069 b600
    00000a0: 6d2a b400 712b c000 18b5 0073 2ab4 0076
    00000b0: b600 3157 2ab4 0034 2ab4 0037 b600 3b57
    00000c0: 2ab4 0079 2ab4 007c b600 3b57 2ab4 0076
    00000d0: 2ab4 0071 2ab4 0034 1d2a b400 7fb9 0047
    00000e0: 0400 c000 2d1d b600 4b57 2ab4 0034 b600
    00000f0: 4f2a b400 79b6 0053 9eff d42a b400 761d
    0000100: 1904 c000 2db6 0080 b0                 
  Stackmap Table:
    same_frame(@11)
    same_locals_1_stack_item_frame(@70,Object[#24])
    full_frame(@204,{Object[#2],Object[#5],Integer,Integer,Object[#5]},{Object[#45],Object[#45]})

    at java.base/java.lang.Class.getDeclaredConstructors0(Native Method)
    at java.base/java.lang.Class.privateGetDeclaredConstructors(Class.java:3549)
    at java.base/java.lang.Class.getConstructor0(Class.java:3754)
    at java.base/java.lang.Class.getDeclaredConstructor(Class.java:2930)
    at arb4j/arb.expressions.Expression.constructNewInstance(Expression.java:1183)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:1171)
    at arb4j/arb.expressions.nodes.nary.NAryOperation.generateFactorClass(NAryOperation.java:308)
    at arb4j/arb.expressions.nodes.nary.NAryOperation.generate(NAryOperation.java:102)
    at arb4j/arb.expressions.Expression.generateEvaluationMethod(Expression.java:1002)
    at arb4j/arb.expressions.Expression.compile(Expression.java:762)
    at arb4j/arb.expressions.Compiler.express(Compiler.java:143)
    at arb4j/arb.expressions.Compiler.express(Compiler.java:156)
    at arb4j/arb.expressions.Compiler.express(Compiler.java:109)
    at arb4j/arb.expressions.Expression.instantiate(Expression.java:150)
    at arb4j/arb.functions.real.RealFunction.express(RealFunction.java:635)
    at arb4j/arb.functions.real.RealFunction.express(RealFunction.java:630)
    at arb4j/arb.functions.polynomials.HypergeometricPolynomial.<init>(HypergeometricPolynomial.java:69)
    at arb4j/arb.functions.polynomials.HypergeometricPolynomial.main(HypergeometricPolynomial.java:33)
```]