
23 Jul
2008
23 Jul
'08
2:12 a.m.
Darrin Thompson wrote:
I'm stuck on something that I thought would be easy.
I have a matrix and a vector.
module Main where import Data.Vector.Dense import Data.Matrix.Dense import BLAS.Matrix.Solve
m = listMatrix (2, 3) ([1, 2, 3, 4, 5, 6]::[Double]) v = listVector 2 ([1, 2]::[Double])
main = do ???
Can I use one of the haskell libraries to solve that system? My goal is to automate some tedium on small exercises from the Linear Algebra text by Jim Heffron.
-- Darrin
Using hmatrix:
import Numeric.LinearAlgebra
m = (2><3) [1, 2, 3, 4, 5, 6]
v = 2 |> [1, 2 :: Double]
sol = m <\> v
$ ghci solve.hs *Main> sol 3 |> [-5.555555555555511e-2,0.11111111111111113,0.2777777777777776] Best regards, Alberto