MCPcopy Create free account
hub / github.com/cockroachdb/apd / GCD

Method GCD

bigint.go:554–572  ·  view source on GitHub ↗

GCD calls (big.Int).GCD.

(x, y, a, b *BigInt)

Source from the content-addressed store, hash-verified

552
553// GCD calls (big.Int).GCD.
554func (z *BigInt) GCD(x, y, a, b *BigInt) *BigInt {
555 var tmp1, tmp2, tmp3, tmp4, tmp5 big.Int //gcassert:noescape
556 zi := z.inner(&tmp1)
557 ai := a.inner(&tmp2)
558 bi := b.inner(&tmp3)
559 xi := x.innerOrNil(&tmp4)
560 // NOTE: innerOrNilOrAlias for the y param because (big.Int).GCD needs to
561 // detect when y is aliased to b. See "avoid aliasing b" in lehmerGCD.
562 yi := y.innerOrNilOrAlias(&tmp5, b, bi)
563 zi.GCD(xi, yi, ai, bi)
564 z.updateInner(zi)
565 if xi != nil {
566 x.updateInner(xi)
567 }
568 if yi != nil {
569 y.updateInner(yi)
570 }
571 return z
572}
573
574// GobEncode calls (big.Int).GobEncode.
575func (z *BigInt) GobEncode() ([]byte, error) {

Callers 4

TestBigIntModInverseFunction · 0.80
checkGcdFunction · 0.80
testGcdFunction · 0.80

Calls 4

innerMethod · 0.95
updateInnerMethod · 0.95
innerOrNilMethod · 0.80
innerOrNilOrAliasMethod · 0.80

Tested by 4

TestBigIntModInverseFunction · 0.64
checkGcdFunction · 0.64
testGcdFunction · 0.64