From 04acd2ad79f7fddb1e6fa9029638378ac9fa8a66 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Fri, 3 Jul 2015 14:39:29 +0200 Subject: fix subMatrix tot and test --- packages/base/src/Internal/Matrix.hs | 1 + packages/base/src/Internal/Modular.hs | 3 ++- 2 files changed, 3 insertions(+), 1 deletion(-) diff --git a/packages/base/src/Internal/Matrix.hs b/packages/base/src/Internal/Matrix.hs index a7fcb47..792fe35 100644 --- a/packages/base/src/Internal/Matrix.hs +++ b/packages/base/src/Internal/Matrix.hs @@ -365,6 +365,7 @@ subMatrix :: Element a -> Matrix a -- ^ input matrix -> Matrix a -- ^ result subMatrix (r0,c0) (rt,ct) m + | rt <= 0 || ct <= 0 = matrixFromVector RowMajor (max 0 rt) (max 0 ct) (fromList []) | 0 <= r0 && 0 <= rt && r0+rt <= rows m && 0 <= c0 && 0 <= ct && c0+ct <= cols m = res | otherwise = error $ "wrong subMatrix "++show ((r0,c0),(rt,ct))++" of "++shSize m diff --git a/packages/base/src/Internal/Modular.hs b/packages/base/src/Internal/Modular.hs index 1d8f761..64ed2bb 100644 --- a/packages/base/src/Internal/Modular.hs +++ b/packages/base/src/Internal/Modular.hs @@ -442,7 +442,7 @@ test = (ok, info) , (checkGen (gen 5 :: Matrix R)) < 1E-15 , (checkGen (gen 5 :: Matrix Float)) < 2E-7 , (checkGen (cgen 5 :: Matrix C)) < 1E-15 - , (checkGen (sgen 5 :: Matrix (Complex Float))) < 2E-7 + , (checkGen (sgen 5 :: Matrix (Complex Float))) < 3E-7 , (checkGen (gen 5 :: Matrix (Mod 7 I))) == 0 , (checkGen (gen 5 :: Matrix (Mod 7 Z))) == 0 , (checkLU (magnit 1E-10) (gen 5 :: Matrix R)) < 2E-15 @@ -461,6 +461,7 @@ test = (ok, info) , gm <> gm == konst 0 (3,3) , lgm <> lgm == konst 0 (3,3) , invershur tmm == luSolve' (luPacked' tmm) (ident (rows tmm)) + , luSolve' (luPacked' (tr $ ident 5 :: Matrix (I ./. 2))) (ident 5) == ident 5 ] -- cgit v1.2.3