Created
August 10, 2020 10:51
-
-
Save 0xkohe/abc5d6d4c5a920248ac3be026891c6ec to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//(a+b√5)(c+d√5) = (ac+5bd)+(ad+bc)√5 | |
func fibMul(t1, t2 fibNum) (r fibNum) { | |
//(ac+5bd) | |
var r1, r2 *big.Rat | |
tmp1 := new(big.Rat).Mul(t1.num, t2.num) | |
tmp2 := new(big.Rat).Mul( | |
new(big.Rat).Mul(t1.numMultipliedBySR, t2.numMultipliedBySR), | |
big.NewRat(5, 1), | |
) | |
r1 = new(big.Rat).Add(tmp1, tmp2) | |
//(ad+bc)√5 | |
tmp3 := new(big.Rat).Mul(t1.num, t2.numMultipliedBySR) | |
tmp4 := new(big.Rat).Mul(t1.numMultipliedBySR, t2.num) | |
r2 = new(big.Rat).Add(tmp3, tmp4) | |
//(ac+5bd)+(ad+bc)√5 | |
//new(big.Rat).Add(r3, rr3) | |
r.num = r1 | |
r.numMultipliedBySR = r2 | |
return | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment