1

I wanted to use hmatrix but it insists on Double and this gives rounding errors sometimes. Looking at the source, I tried

type instance DoubleOf Rational = Rational

but DoubleOf is not exported (Numeric.ContainerBool is hidden), and that's probably for a reason.

Wahyu Kristianto
  • 8,719
  • 6
  • 43
  • 68
d8d0d65b3f7cf42
  • 2,597
  • 15
  • 28
  • 2
    Have you tried [this numeric matrix package](http://hackage.haskell.org/package/bed-and-breakfast)? Apparently it claims to do what you want. – fizruk May 22 '14 at 09:06

1 Answers1

4

You can perform exact operations on matrices using bed-and-breakfast package.

Here's sample ghci session:

>>> import Numeric.Matrix
>>> import Data.Ratio
>>> let m = fromList [[1 % 2, 2 % 3], [3 % 4, 4 % 5]] :: Matrix Rational
>>> det m
(-1) % 10
>>> m * m
 3 % 4  13 % 15
 39 % 40  57 % 50

>>> m^4
 563 % 400  819 % 500
 7371 % 4000  10723 % 5000
fizruk
  • 1,855
  • 14
  • 24