summaryrefslogtreecommitdiff
path: root/packages/base/src/Internal/LAPACK.hs
diff options
context:
space:
mode:
authorDominic Steinitz <dominic@steinitz.org>2017-03-21 17:35:43 +0000
committerDominic Steinitz <dominic@steinitz.org>2017-03-21 17:35:43 +0000
commit49d718705d205d62aea2762445f95735a671f305 (patch)
tree589b5c4396647f48b941d313432647ecb53ef606 /packages/base/src/Internal/LAPACK.hs
parentfa1642dcf26f1da0a6f4c1324bcd1e8baf9fd478 (diff)
Add tridiagonal solver and tests for it and triagonal solver.
Diffstat (limited to 'packages/base/src/Internal/LAPACK.hs')
-rw-r--r--packages/base/src/Internal/LAPACK.hs22
1 files changed, 22 insertions, 0 deletions
diff --git a/packages/base/src/Internal/LAPACK.hs b/packages/base/src/Internal/LAPACK.hs
index b4dd5cf..e306454 100644
--- a/packages/base/src/Internal/LAPACK.hs
+++ b/packages/base/src/Internal/LAPACK.hs
@@ -436,6 +436,28 @@ triSolveC :: UpLo -> Matrix (Complex Double) -> Matrix (Complex Double) -> Matri
436triSolveC Lower a b = linearSolveTRAux2 id ztrtrs_l "triSolveC" (fmat a) b 436triSolveC Lower a b = linearSolveTRAux2 id ztrtrs_l "triSolveC" (fmat a) b
437triSolveC Upper a b = linearSolveTRAux2 id ztrtrs_u "triSolveC" (fmat a) b 437triSolveC Upper a b = linearSolveTRAux2 id ztrtrs_u "triSolveC" (fmat a) b
438 438
439--------------------------------------------------------------------------------
440foreign import ccall unsafe "triDiagSolveR_l" dgttrs :: R :> R :> R :> R ::> Ok
441foreign import ccall unsafe "triDiagSolveC_l" zgttrs :: C :> C :> C :> C ::> Ok
442
443linearSolveGTAux2 g f st dl d du b
444 | ndl == nd - 1 &&
445 ndu == nd - 1 &&
446 nd == r = unsafePerformIO . g $ do
447 s <- copy ColumnMajor b
448 (dl # d # du #! s) f #| st
449 return s
450 | otherwise = error $ st ++ " of nonsquare matrix"
451 where
452 ndl = dim dl
453 nd = dim d
454 ndu = dim du
455 r = rows b
456
457-- | Solves a tridiagonal system of linear equations.
458triDiagSolveR dl d du b = linearSolveGTAux2 id dgttrs "triDiagSolveR" dl d du b
459triDiagSolveC dl d du b = linearSolveGTAux2 id zgttrs "triDiagSolveC" dl d du b
460
439----------------------------------------------------------------------------------- 461-----------------------------------------------------------------------------------
440 462
441foreign import ccall unsafe "linearSolveLSR_l" dgels :: R ::> R ::> Ok 463foreign import ccall unsafe "linearSolveLSR_l" dgels :: R ::> R ::> Ok