Lines Matching refs:g2
415 # g2 = gcd(t, d) == gcd(t, (da//g)*(db//g)*g) == gcd(t, g)
417 # t//g2 t//g2
419 # (da//g)*(db//g)*(g//g2) (da//g)*(db//g2)
424 # We should special-case g == 1 (and g2 == 1), since 60.8% of
427 # Note, that g2 == 1 always for fractions, obtained from floats: here
432 # Let g1 = gcd(na, db) and g2 = gcd(nb, da), then
434 # na*nb na*nb (na//g1)*(nb//g2)
436 # da*db db*da (db//g1)*(da//g2)
444 # Indeed, pick (na//g1). It's coprime with (da//g2), because input
449 # and g2 == 1 for same reason. That happens also for multiplying
461 g2 = math.gcd(t, g)
462 if g2 == 1:
464 return Fraction(t // g2, s * (db // g2), _normalize=False)
477 g2 = math.gcd(t, g)
478 if g2 == 1:
480 return Fraction(t // g2, s * (db // g2), _normalize=False)
492 g2 = math.gcd(nb, da)
493 if g2 > 1:
494 nb //= g2
495 da //= g2
509 g2 = math.gcd(db, da)
510 if g2 > 1:
511 da //= g2
512 db //= g2