haskellhmatrix

Haskell - Instance Declaration on hMatrix


I'm using the function fromBlocks from hMatrix over a list whose elements are determined by functions of type Int -> Int -> Int -> Matrix Int. However, GHC complains saying that:

No instance for (Element Int) arising from a use of `fromBlocks'
    Possible fix: add an instance declaration for (Element Int)
    In the expression:
      fromBlocks [[matrixCreate n m d], [rowZero n m d]]

I tried to tell GHC the type of the result of this computation with :: Matrix Int but it didn't work, and I don't understand how to declare the type when using the function.


Solution

  • No - there is really no instance for Element Int - see here: http://hackage.haskell.org/package/hmatrix-0.16.0.3/docs/Numeric-LinearAlgebra-HMatrix.html#t:Element

    Just go for Matrix Float or Matrix Double if you can