summaryrefslogtreecommitdiff
path: root/lib/GSL/Polynomials.hs
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-10-01 15:04:16 +0000
committerAlberto Ruiz <aruiz@um.es>2007-10-01 15:04:16 +0000
commitc99b8fd6e3f8a2fb365ec12baf838f864b118ece (patch)
tree11b5b8515861fe88d547253ae10c2182d5fadaf2 /lib/GSL/Polynomials.hs
parent768f08d4134a066d773d56a9c03ae688e3850352 (diff)
LinearAlgebra and GSL moved to Numeric
Diffstat (limited to 'lib/GSL/Polynomials.hs')
-rw-r--r--lib/GSL/Polynomials.hs54
1 files changed, 0 insertions, 54 deletions
diff --git a/lib/GSL/Polynomials.hs b/lib/GSL/Polynomials.hs
deleted file mode 100644
index a87fa56..0000000
--- a/lib/GSL/Polynomials.hs
+++ /dev/null
@@ -1,54 +0,0 @@
1{-# OPTIONS_GHC -fglasgow-exts #-}
2-----------------------------------------------------------------------------
3{- |
4Module : GSL.Polynomials
5Copyright : (c) Alberto Ruiz 2006
6License : GPL-style
7
8Maintainer : Alberto Ruiz (aruiz at um dot es)
9Stability : provisional
10Portability : uses ffi
11
12Polynomials.
13
14<http://www.gnu.org/software/gsl/manual/html_node/General-Polynomial-Equations.html#General-Polynomial-Equations>
15
16-}
17-----------------------------------------------------------------------------
18module GSL.Polynomials (
19 polySolve
20) where
21
22import Data.Packed.Internal
23import Complex
24import Foreign
25
26{- | Solution of general polynomial equations, using /gsl_poly_complex_solve/. For example,
27 the three solutions of x^3 + 8 = 0
28
29@\> polySolve [8,0,0,1]
30[(-1.9999999999999998) :+ 0.0,
31 1.0 :+ 1.732050807568877,
32 1.0 :+ (-1.732050807568877)]@
33
34The example in the GSL manual: To find the roots of x^5 -1 = 0:
35
36@\> polySolve [-1, 0, 0, 0, 0, 1]
37[(-0.8090169943749475) :+ 0.5877852522924731,
38(-0.8090169943749475) :+ (-0.5877852522924731),
390.30901699437494734 :+ 0.9510565162951536,
400.30901699437494734 :+ (-0.9510565162951536),
411.0 :+ 0.0]@
42
43-}
44polySolve :: [Double] -> [Complex Double]
45polySolve = toList . polySolve' . fromList
46
47polySolve' :: Vector Double -> Vector (Complex Double)
48polySolve' v | dim v > 1 = unsafePerformIO $ do
49 r <- createVector (dim v-1)
50 c_polySolve // vec v // vec r // check "polySolve" [v]
51 return r
52 | otherwise = error "polySolve on a polynomial of degree zero"
53
54foreign import ccall "gsl-aux.h polySolve" c_polySolve:: TVCV