From f4124fa6209cbf8290fed2be51cec8464bf7f1b9 Mon Sep 17 00:00:00 2001 From: Maxim Koltsov Date: Mon, 19 Nov 2018 20:43:22 +0300 Subject: Fix #282 LAPACK routine dgttrf mutates its inputs per documentation. To prevent user-visible breakage input vectors must be copied before sending them to LAPACK. --- packages/base/src/Internal/LAPACK.hs | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'packages/base/src/Internal') diff --git a/packages/base/src/Internal/LAPACK.hs b/packages/base/src/Internal/LAPACK.hs index ff55688..27d1f95 100644 --- a/packages/base/src/Internal/LAPACK.hs +++ b/packages/base/src/Internal/LAPACK.hs @@ -506,8 +506,10 @@ linearSolveGTAux2 g f st dl d du b | ndl == nd - 1 && ndu == nd - 1 && nd == r = unsafePerformIO . g $ do + dl' <- head . toRows <$> copy ColumnMajor (fromRows [dl]) + du' <- head . toRows <$> copy ColumnMajor (fromRows [du]) s <- copy ColumnMajor b - (dl # d # du #! s) f #| st + (dl' # d # du' #! s) f #| st return s | otherwise = error $ st ++ " of nonsquare matrix" where -- cgit v1.2.3