MCPcopy
hub / github.com/ethereum/EIPs / ln_recur

Function ln_recur

assets/eip-7543/decimal_float.go:506–537  ·  view source on GitHub ↗

out !== a

(a, two_y_plus_x *Decimal, precision, max_steps, step *int256, gas *uint64)

Source from the content-addressed store, hash-verified

504
505// out !== a
506func ln_recur(a, two_y_plus_x *Decimal, precision, max_steps, step *int256, gas *uint64) *Decimal {
507 var out Decimal
508
509 // (2*step-1)*(2+x)
510 stepDec := createDecimal(step, ZERO_INT256, gas)
511 stepDec.Mul(stepDec, TWO_DECIMAL, precision, gas)
512 stepDec.Add(stepDec, MINUS_ONE_DECIMAL, precision, gas)
513 out.Mul(stepDec, two_y_plus_x, precision, gas)
514
515 // end recursion?
516 if Cmp(max_steps, step, gas) == 0 {
517 return &out
518 }
519
520 // recursion
521 Add(step, ONE_INT256, step, gas)
522 r := ln_recur(a, two_y_plus_x, precision, max_steps, step, gas)
523 Sub(step, ONE_INT256, step, gas)
524 r.Inv(r, precision, gas)
525
526 // (step*x)^2
527 stepDec2 := createDecimal(step, ZERO_INT256, gas)
528 stepDec2.Mul(stepDec2, a, precision, gas)
529 stepDec2.Mul(stepDec2, stepDec2, precision, gas)
530
531 r.Mul(stepDec2, r, precision, gas)
532 r.Neg(r, gas)
533
534 out.Add(&out, r, precision, gas)
535
536 return &out
537}

Callers 1

lnMethod · 0.85

Calls 8

MulMethod · 0.95
AddMethod · 0.95
createDecimalFunction · 0.85
CmpFunction · 0.85
AddFunction · 0.85
SubFunction · 0.85
InvMethod · 0.80
NegMethod · 0.80

Tested by

no test coverage detected