diff options
Diffstat (limited to 'lib/Numeric/GSL/Root.hs')
-rw-r--r-- | lib/Numeric/GSL/Root.hs | 8 |
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 | |||
76 | rootGen m f xi epsabs maxit = unsafePerformIO $ do | 76 | rootGen 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 | |||
119 | checkdim 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 | ||