summaryrefslogtreecommitdiff
path: root/packages/tests
diff options
context:
space:
mode:
authorMaxim Koltsov <kolmax94@gmail.com>2018-11-19 20:43:22 +0300
committerMaxim Koltsov <kolmax94@gmail.com>2018-11-19 20:44:37 +0300
commitf4124fa6209cbf8290fed2be51cec8464bf7f1b9 (patch)
tree7e1cf379a31fe3f83ae1ce5a3b1feaaad11223fa /packages/tests
parent480c4db1585ed122dfc491bb15421565966dad66 (diff)
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.
Diffstat (limited to 'packages/tests')
-rw-r--r--packages/tests/src/Numeric/LinearAlgebra/Tests.hs24
1 files changed, 24 insertions, 0 deletions
diff --git a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
index c0c151a..3c7863f 100644
--- a/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
+++ b/packages/tests/src/Numeric/LinearAlgebra/Tests.hs
@@ -242,6 +242,29 @@ triDiagTest = utest "triDiagTest" (ok1 && ok2) where
242 242
243--------------------------------------------------------------------- 243---------------------------------------------------------------------
244 244
245triDiagRegression = utest "triDiagRegression" ok where
246 minusOnes, twos :: Vector R
247 minusOnes = fromList [-1, -1]
248 twos = fromList [2, 2, 2]
249 k :: Matrix R
250 k = (3><3)
251 [ 2, -1, 0
252 , -1, 2, -1
253 , 0, -1, 2
254 ]
255
256 b :: Matrix R
257 b = (3><1) [10, 10, 10]
258
259 tridiag = triDiagSolve minusOnes twos minusOnes b
260 simple = linearSolve k b
261
262 ok = case simple of
263 Just m -> tridiag |~| m
264 Nothing -> False
265
266---------------------------------------------------------------------
267
245randomTestGaussian = (unSym c) :~3~: unSym (snd (meanCov dat)) 268randomTestGaussian = (unSym c) :~3~: unSym (snd (meanCov dat))
246 where 269 where
247 a = (3><3) [1,2,3, 270 a = (3><3) [1,2,3,
@@ -830,6 +853,7 @@ runTests n = do
830 , mbCholTest 853 , mbCholTest
831 , triTest 854 , triTest
832 , triDiagTest 855 , triDiagTest
856 , triDiagRegression
833 , utest "offset" offsetTest 857 , utest "offset" offsetTest
834 , normsVTest 858 , normsVTest
835 , normsMTest 859 , normsMTest