Purely functional interface to basic linear algebra and other numerical computations, internally implemented using GSL, BLAS and LAPACK.
Questions tagged [hmatrix]
35 questions
2
votes
1 answer
How to calculate gradient of a matrix using hmatrix in Haskell?
Recently I've been trying to use JuicyPixels and hmatrix to process images.
However, I don't know how to calculate the gradient of a matrix as image gradient using hmatrix. There seems to be no available API and I can only write a one myself which…

xuehy
- 23
- 5
2
votes
1 answer
hmatrix install error issue with sandbox?
I installed hmatrix in a sandbox, which gets through the install process but then then linker hangs up with...
Linking dist/dist-sandbox-34d68aef/build/wavelets/wavelets ...
/usr/bin/ld: cannot find -lHSwavelets-0.1.0_p
/usr/bin/ld: cannot find…

TallerGhostWalt
- 464
- 3
- 11
1
vote
1 answer
Can I load a Numeric.LinearAlgebra.Static vector from a pointer
I want to pass double-arrays to/from a Fortran77 library with Foreign.Marshal.Array, but in my Haskell code, I want to use statically sized vectors from Numeric.LinearAlgebra.Static. My minimal example attempt is the below.
{-# LANGUAGE DataKinds…

LudvigH
- 3,662
- 5
- 31
- 49
1
vote
1 answer
Mutable list of mutabale non-integral types in Haskell
I'm trying to parse a huge 3d-data array of complex values from binary. Later this should become l matrices (n x m). Since I'm going to work on these matrices, I'm limited to matrix libraries - hmatrix seems to be promising.
The data layout is not…

blauerreimers
- 161
- 7
1
vote
1 answer
Apply element-wise mathematical function using hmatrix (with vectorization)
I need to apply a function on elements of a vector in Haskell in an efficient way, which implies that i am not looking for something like this:
sigmoid :: [Float] -> [Float]
sigmoid [] = []
sigmoid (z:zs) = ( 1/(1+exp (-z)) ):(sigmoid zs)
To be…

mahmoud fathy
- 361
- 1
- 7
- 17
1
vote
2 answers
Why does (-) fail to typecheck when I place a Double Matrix on the left and a Double on the right?
Since hmatrix provides an instance of Num for Matrix types, I can express element-wise subtraction like:
m = (2><2)[1..] :: Double Matrix
m' = m - 3
That works great, as 3 is a Num, and results in a matrix created by subtracting 3 from each element…

nclark
- 1,022
- 1
- 11
- 16
1
vote
1 answer
How to remove commas and brackets from a list ( hmatrix )
For plotting a graphic in gnuplot
I'm trying to print this matrix into a file, but for it to be executed into gnuplot I need to create a file without the commas and brackets, how do I do that?
*install hmatrix
*install hmatrix-special
*import…
user6510571
1
vote
1 answer
how to add two matrices in haskell
I am trying to use Haskell's Linear Algebra library to compute some eigenvalues, but first I need to try to add matrices first.
import Numeric.LinearAlgebra.Data
matrix 3 [1,2,3,4,5,6,7,8,9 ] + matrix 3 [1,2,3,4,5,6,7,8,9 ]
(3><3)
[ 2.0, 4.0, …

john mangual
- 7,718
- 13
- 56
- 95
1
vote
0 answers
hmatrix eigenvalues differ from R?
I am trying to follow some simple hmatrix examples:
import qualified Numeric.LinearAlgebra as La
w = 4 La.|> [2, 0, -3, 0 :: Double]
m = (3 La.>< 4) [1::Double ..]
x = La.singularValues m
x' = sqrt . La.eigenvalues $ m La.<> La.trans m
Load into…

qed
- 22,298
- 21
- 125
- 196
1
vote
0 answers
building hmatrix on OSX
I'm trying to build hmatrix-0.16.1.1 on OSX 10.10.1, and I'm running into some undefined C functions and types in src/C/vector-aux.c:
struct random_data
random_r()
initstate_r()
A specific error:
src/C/vector-aux.c:738:24:
error: variable has…

ErikR
- 51,541
- 9
- 73
- 124
1
vote
3 answers
Haskell - Type incompatibility after qualified import
I'm using hMatrix and the first lines of my code are:
import Numeric.LinearAlgebra
import qualified Data.Vector as V
The problem is that in my code the vector type is V.Vector, but some methods defined by hMatrix have type Vector -> ... and GHC…

guaraqe
- 249
- 1
- 7
1
vote
2 answers
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'
…

guaraqe
- 249
- 1
- 7
1
vote
1 answer
How can I compute an exact (integer) determinant in Haskell?
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…

d8d0d65b3f7cf42
- 2,597
- 15
- 28
0
votes
0 answers
Couldn't import Data.Packed.Matrix
This is my package.yaml:
dependencies:
- base >= 4.7 && < 5
- hmatrix
- vector
my imports:
import Prelude hiding ( (<>) )
import Numeric.LinearAlgebra
import **Data.Packed.Matrix**
import qualified Data.Vector as V
I would…

user3680029
- 179
- 8
0
votes
0 answers
Pattern matching on hmatrix Vector type in haskell
That question sounds trivial but I really can't find anything helping me on how to deal with it.
Here's a simple example to reproduce that on Haskell :
import Numeric.LinearAlgebra.HMatrix
madd :: Double -> Vector Double -> Vector Double
madd a v…

mahmoud fathy
- 361
- 1
- 7
- 17