diff options
author | Dominic Steinitz <dominic@steinitz.org> | 2017-03-21 17:35:43 +0000 |
---|---|---|
committer | Dominic Steinitz <dominic@steinitz.org> | 2017-03-21 17:35:43 +0000 |
commit | 49d718705d205d62aea2762445f95735a671f305 (patch) | |
tree | 589b5c4396647f48b941d313432647ecb53ef606 /packages/base/src/Internal/LAPACK.hs | |
parent | fa1642dcf26f1da0a6f4c1324bcd1e8baf9fd478 (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.hs | 22 |
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 | |||
436 | triSolveC Lower a b = linearSolveTRAux2 id ztrtrs_l "triSolveC" (fmat a) b | 436 | triSolveC Lower a b = linearSolveTRAux2 id ztrtrs_l "triSolveC" (fmat a) b |
437 | triSolveC Upper a b = linearSolveTRAux2 id ztrtrs_u "triSolveC" (fmat a) b | 437 | triSolveC Upper a b = linearSolveTRAux2 id ztrtrs_u "triSolveC" (fmat a) b |
438 | 438 | ||
439 | -------------------------------------------------------------------------------- | ||
440 | foreign import ccall unsafe "triDiagSolveR_l" dgttrs :: R :> R :> R :> R ::> Ok | ||
441 | foreign import ccall unsafe "triDiagSolveC_l" zgttrs :: C :> C :> C :> C ::> Ok | ||
442 | |||
443 | linearSolveGTAux2 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. | ||
458 | triDiagSolveR dl d du b = linearSolveGTAux2 id dgttrs "triDiagSolveR" dl d du b | ||
459 | triDiagSolveC dl d du b = linearSolveGTAux2 id zgttrs "triDiagSolveC" dl d du b | ||
460 | |||
439 | ----------------------------------------------------------------------------------- | 461 | ----------------------------------------------------------------------------------- |
440 | 462 | ||
441 | foreign import ccall unsafe "linearSolveLSR_l" dgels :: R ::> R ::> Ok | 463 | foreign import ccall unsafe "linearSolveLSR_l" dgels :: R ::> R ::> Ok |