Created
April 3, 2015 13:34
-
-
Save aakashns/6d96372c7ae59d5168f4 to your computer and use it in GitHub Desktop.
pari group for rationsl
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
| object RationalGroup extends Group[(Int, Int)] { | |
| val zero = (0, 0) | |
| def plus(x: (Int, Int), y: (Int, Int)): (Int, Int) = (x, y) match { | |
| case ((x1, x2), (y1, y2)) => (x1*y2 + x2*y1, x2*y2) | |
| } | |
| def inverse(x: (Int, Int)) = (-x._1, x._2) | |
| } | |
| sum(Seq((1, 1), (4, 8), (9, 27), (25, 125), (64, 512)))(RationalGroup) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment