summaryrefslogtreecommitdiff
path: root/lib
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2009-06-05 18:53:07 +0000
committerAlberto Ruiz <aruiz@um.es>2009-06-05 18:53:07 +0000
commit49a3d719221cd9484a64688ffcdbeb13cb8e55a0 (patch)
treefbe5161936acb1f49d1337c2da1f7f93139c089a /lib
parentbbc54bf2573ea3631ee436507807dae6c4353bcc (diff)
check dim in root function
Diffstat (limited to 'lib')
-rw-r--r--lib/Numeric/GSL/Root.hs8
1 files changed, 7 insertions, 1 deletions
diff --git a/lib/Numeric/GSL/Root.hs b/lib/Numeric/GSL/Root.hs
index ad1b72c..d674fad 100644
--- a/lib/Numeric/GSL/Root.hs
+++ b/lib/Numeric/GSL/Root.hs
@@ -76,7 +76,7 @@ root method epsabs maxit fun xinit = rootGen (fi (fromEnum method)) fun xinit ep
76rootGen m f xi epsabs maxit = unsafePerformIO $ do 76rootGen m f xi epsabs maxit = unsafePerformIO $ do
77 let xiv = fromList xi 77 let xiv = fromList xi
78 n = dim xiv 78 n = dim xiv
79 fp <- mkVecVecfun (aux_vTov (fromList.f.toList)) 79 fp <- mkVecVecfun (aux_vTov (fromList . checkdim n f . toList))
80 rawpath <- withVector xiv $ \xiv' -> 80 rawpath <- withVector xiv $ \xiv' ->
81 createMIO maxit (2*n+1) 81 createMIO maxit (2*n+1)
82 (c_root m fp epsabs (fi maxit) // xiv') 82 (c_root m fp epsabs (fi maxit) // xiv')
@@ -115,3 +115,9 @@ createMIO r c fun msg = do
115 res <- createMatrix RowMajor r c 115 res <- createMatrix RowMajor r c
116 app1 fun mat res msg 116 app1 fun mat res msg
117 return res 117 return res
118
119checkdim n f x
120 | length y /= n = error $ "Error: "++ show n
121 ++ " results expected in the function supplied to root"
122 | otherwise = y
123 where y = f x