{-# LANGUAGE TypeFamilies #-}
{-# LANGUAGE ConstraintKinds #-}
module Numeric.LAPACK.Matrix.Triangular.Eigen (
   values,
   decompose,
   ) where

import qualified Numeric.LAPACK.Matrix.Triangular.Basic as Triangular
import qualified Numeric.LAPACK.Matrix.Shape.Private as MatrixShape
import Numeric.LAPACK.Matrix.Triangular.Private
         (unpackZero, pack, unpackToTemp, fillTriangle,
          forPointers, rowMajorPointers)
import Numeric.LAPACK.Matrix.Triangular.Basic (Triangular)
import Numeric.LAPACK.Matrix.Shape.Private
         (Order(ColumnMajor,RowMajor), caseLoUp, uploOrder, NonUnit(NonUnit))
import Numeric.LAPACK.Vector (Vector)
import Numeric.LAPACK.Scalar (zero)
import Numeric.LAPACK.Private (lacgv, withInfo, errorCodeMsg)

import qualified Numeric.LAPACK.FFI.Complex as LapackComplex
import qualified Numeric.LAPACK.FFI.Real as LapackReal
import qualified Numeric.BLAS.FFI.Generic as BlasGen
import qualified Numeric.Netlib.Utility as Call
import qualified Numeric.Netlib.Class as Class

import qualified Data.Array.Comfort.Storable.Unchecked.Monadic as ArrayIO
import qualified Data.Array.Comfort.Storable.Unchecked as Array
import qualified Data.Array.Comfort.Shape as Shape
import Data.Array.Comfort.Storable.Unchecked (Array(Array))
import Data.Array.Comfort.Shape (triangleSize)

import Foreign.C.Types (CInt, CChar)
import Foreign.Ptr (Ptr, nullPtr)

import Control.Monad.Trans.Cont (evalContT)
import Control.Monad.IO.Class (liftIO)

import Data.Complex (Complex)
import Data.Tuple.HT (swap)


values ::
   (MatrixShape.DiagUpLo lo up, Shape.C sh, Class.Floating a) =>
   Triangular lo diag up sh a -> Vector sh a
values :: Triangular lo diag up sh a -> Vector sh a
values = Triangular lo diag up sh a -> Vector sh a
forall lo up sh a diag.
(Content lo, Content up, C sh, Floating a) =>
Triangular lo diag up sh a -> Vector sh a
Triangular.takeDiagonal


decompose ::
   (MatrixShape.DiagUpLo lo up, Shape.C sh, Class.Floating a) =>
   Triangular lo NonUnit up sh a ->
   (Triangular lo NonUnit up sh a, Vector sh a, Triangular lo NonUnit up sh a)
decompose :: Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Vector sh a,
    Triangular lo NonUnit up sh a)
decompose Triangular lo NonUnit up sh a
a =
   let (Triangular lo NonUnit up sh a
vr,Triangular lo NonUnit up sh a
vl) =
         (Decompose sh a lo up
 -> Triangular lo NonUnit up sh a
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> Triangular lo NonUnit up sh a
-> Decompose sh a lo up
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a b c. (a -> b -> c) -> b -> a -> c
flip Decompose sh a lo up
-> Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall sh a lo up.
Decompose sh a lo up
-> Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
getDecompose Triangular lo NonUnit up sh a
a (Decompose sh a lo up
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> Decompose sh a lo up
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a b. (a -> b) -> a -> b
$
         Decompose sh a Empty Empty
-> Decompose sh a Empty Filled
-> Decompose sh a Filled Empty
-> Decompose sh a lo up
forall lo up (f :: * -> * -> *).
DiagUpLoC lo up =>
f Empty Empty -> f Empty Filled -> f Filled Empty -> f lo up
MatrixShape.switchDiagUpLo
            ((Triangular Empty NonUnit Empty sh a
 -> (Triangular Empty NonUnit Empty sh a,
     Triangular Empty NonUnit Empty sh a))
-> Decompose sh a Empty Empty
forall sh a lo up.
(Triangular lo NonUnit up sh a
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> Decompose sh a lo up
Decompose ((Triangular Empty NonUnit Empty sh a
  -> (Triangular Empty NonUnit Empty sh a,
      Triangular Empty NonUnit Empty sh a))
 -> Decompose sh a Empty Empty)
-> (Triangular Empty NonUnit Empty sh a
    -> (Triangular Empty NonUnit Empty sh a,
        Triangular Empty NonUnit Empty sh a))
-> Decompose sh a Empty Empty
forall a b. (a -> b) -> a -> b
$
               (\Triangular Empty NonUnit Empty sh a
eye -> (Triangular Empty NonUnit Empty sh a
eye, Triangular Empty NonUnit Empty sh a
-> Triangular Empty NonUnit Empty sh a
forall lo up diag sh a.
(Content lo, Content up, TriDiag diag) =>
Triangular lo diag up sh a -> Triangular up diag lo sh a
Triangular.transpose Triangular Empty NonUnit Empty sh a
eye)) (Triangular Empty NonUnit Empty sh a
 -> (Triangular Empty NonUnit Empty sh a,
     Triangular Empty NonUnit Empty sh a))
-> (Triangular Empty NonUnit Empty sh a
    -> Triangular Empty NonUnit Empty sh a)
-> Triangular Empty NonUnit Empty sh a
-> (Triangular Empty NonUnit Empty sh a,
    Triangular Empty NonUnit Empty sh a)
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
               Triangular Empty Unit Empty sh a
-> Triangular Empty NonUnit Empty sh a
forall diag lo up sh a.
TriDiag diag =>
Triangular lo Unit up sh a -> Triangular lo diag up sh a
Triangular.relaxUnitDiagonal (Triangular Empty Unit Empty sh a
 -> Triangular Empty NonUnit Empty sh a)
-> (Triangular Empty NonUnit Empty sh a
    -> Triangular Empty Unit Empty sh a)
-> Triangular Empty NonUnit Empty sh a
-> Triangular Empty NonUnit Empty sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
               Order -> sh -> Triangular Empty Unit Empty sh a
forall lo up sh a.
(Content lo, Content up, C sh, Floating a) =>
Order -> sh -> Triangular lo Unit up sh a
Triangular.identity Order
ColumnMajor (sh -> Triangular Empty Unit Empty sh a)
-> (Triangular Empty NonUnit Empty sh a -> sh)
-> Triangular Empty NonUnit Empty sh a
-> Triangular Empty Unit Empty sh a
forall b c a. (b -> c) -> (a -> b) -> a -> c
.
               Triangular Empty NonUnit Empty sh -> sh
forall lo diag up size. Triangular lo diag up size -> size
MatrixShape.triangularSize (Triangular Empty NonUnit Empty sh -> sh)
-> (Triangular Empty NonUnit Empty sh a
    -> Triangular Empty NonUnit Empty sh)
-> Triangular Empty NonUnit Empty sh a
-> sh
forall b c a. (b -> c) -> (a -> b) -> a -> c
. Triangular Empty NonUnit Empty sh a
-> Triangular Empty NonUnit Empty sh
forall sh a. Array sh a -> sh
Array.shape)
            ((Triangular Empty NonUnit Filled sh a
 -> (Triangular Empty NonUnit Filled sh a,
     Triangular Empty NonUnit Filled sh a))
-> Decompose sh a Empty Filled
forall sh a lo up.
(Triangular lo NonUnit up sh a
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> Decompose sh a lo up
Decompose Triangular Empty NonUnit Filled sh a
-> (Triangular Empty NonUnit Filled sh a,
    Triangular Empty NonUnit Filled sh a)
forall lo up sh a.
(UpLo lo up, C sh, Floating a) =>
Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
decomposeTriangular)
            ((Triangular Filled NonUnit Empty sh a
 -> (Triangular Filled NonUnit Empty sh a,
     Triangular Filled NonUnit Empty sh a))
-> Decompose sh a Filled Empty
forall sh a lo up.
(Triangular lo NonUnit up sh a
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> Decompose sh a lo up
Decompose Triangular Filled NonUnit Empty sh a
-> (Triangular Filled NonUnit Empty sh a,
    Triangular Filled NonUnit Empty sh a)
forall lo up sh a.
(UpLo lo up, C sh, Floating a) =>
Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
decomposeTriangular)
   in  (Triangular lo NonUnit up sh a
vr, Triangular lo NonUnit up sh a -> Vector sh a
forall lo up sh a diag.
(DiagUpLo lo up, C sh, Floating a) =>
Triangular lo diag up sh a -> Vector sh a
values Triangular lo NonUnit up sh a
a, Triangular lo NonUnit up sh a
vl)

newtype Decompose sh a lo up =
   Decompose {
      Decompose sh a lo up
-> Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
getDecompose ::
         Triangular lo NonUnit up sh a ->
         (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
   }

decomposeTriangular ::
   (MatrixShape.UpLo lo up, Shape.C sh, Class.Floating a) =>
   Triangular lo NonUnit up sh a ->
   (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
decomposeTriangular :: Triangular lo NonUnit up sh a
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
decomposeTriangular (Array (MatrixShape.Triangular NonUnit
_diag (lo, up)
uplo Order
order sh
sh) ForeignPtr a
a) =
   let triShape :: Order -> Triangular lo NonUnit up sh
triShape Order
ord =
         NonUnit -> (lo, up) -> Order -> sh -> Triangular lo NonUnit up sh
forall lo diag up size.
diag -> (lo, up) -> Order -> size -> Triangular lo diag up size
MatrixShape.Triangular NonUnit
NonUnit (lo, up)
uplo ((lo, up) -> Order -> Order
forall lo up.
(Content lo, Content up) =>
(lo, up) -> Order -> Order
uploOrder (lo, up)
uplo Order
ord) sh
sh
       n :: Int
n = sh -> Int
forall sh. C sh => sh -> Int
Shape.size sh
sh
       n2 :: Int
n2 = Int
nInt -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n
       triSize :: Int
triSize = Int -> Int
triangleSize Int
n

   in (lo, up)
-> ((Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
    -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> ((Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
    -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall lo up a. UpLo lo up => (lo, up) -> a -> a -> a
caseLoUp (lo, up)
uplo (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a. a -> a
id (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a b. (a, b) -> (b, a)
swap ((Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a b. (a -> b) -> a -> b
$
      Triangular lo NonUnit up sh
-> (Int -> Ptr a -> IO (Triangular lo NonUnit up sh a))
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall sh a b.
(C sh, Storable a) =>
sh -> (Int -> Ptr a -> IO b) -> (Array sh a, b)
Array.unsafeCreateWithSizeAndResult (Order -> Triangular lo NonUnit up sh
triShape Order
RowMajor) ((Int -> Ptr a -> IO (Triangular lo NonUnit up sh a))
 -> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a))
-> (Int -> Ptr a -> IO (Triangular lo NonUnit up sh a))
-> (Triangular lo NonUnit up sh a, Triangular lo NonUnit up sh a)
forall a b. (a -> b) -> a -> b
$ \Int
_ Ptr a
vlpPtr ->
      Triangular lo NonUnit up sh
-> (Ptr a -> IO ()) -> IO (Triangular lo NonUnit up sh a)
forall (m :: * -> *) sh a.
(PrimMonad m, C sh, Storable a) =>
sh -> (Ptr a -> IO ()) -> m (Array sh a)
ArrayIO.unsafeCreate (Order -> Triangular lo NonUnit up sh
triShape Order
ColumnMajor) ((Ptr a -> IO ()) -> IO (Triangular lo NonUnit up sh a))
-> (Ptr a -> IO ()) -> IO (Triangular lo NonUnit up sh a)
forall a b. (a -> b) -> a -> b
$ \Ptr a
vrpPtr ->

   ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> IO ()) -> ContT () IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
      Ptr CChar
sidePtr <- Char -> FortranIO () (Ptr CChar)
forall r. Char -> FortranIO r (Ptr CChar)
Call.char Char
'B'
      Ptr CChar
howManyPtr <- Char -> FortranIO () (Ptr CChar)
forall r. Char -> FortranIO r (Ptr CChar)
Call.char Char
'A'
      let selectPtr :: Ptr a
selectPtr = Ptr a
forall a. Ptr a
nullPtr
      let unpk :: Int -> Ptr a -> Ptr a -> IO ()
unpk =
            case (lo, up) -> Order -> Order
forall lo up.
(Content lo, Content up) =>
(lo, up) -> Order -> Order
uploOrder (lo, up)
uplo Order
order of
               Order
ColumnMajor -> Order -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Order -> Int -> Ptr a -> Ptr a -> IO ()
unpackZero Order
ColumnMajor
               Order
RowMajor -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Int -> Ptr a -> Ptr a -> IO ()
unpackZeroRowMajor
      Ptr a
aPtr <- (Int -> Ptr a -> Ptr a -> IO ())
-> Int -> ForeignPtr a -> ContT () IO (Ptr a)
forall a r.
Storable a =>
(Int -> Ptr a -> Ptr a -> IO ())
-> Int -> ForeignPtr a -> ContT r IO (Ptr a)
unpackToTemp Int -> Ptr a -> Ptr a -> IO ()
unpk Int
n ForeignPtr a
a
      Ptr CInt
ldaPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.leadingDim Int
n
      Ptr a
vlPtr <- Int -> ContT () IO (Ptr a)
forall a r. Storable a => Int -> FortranIO r (Ptr a)
Call.allocaArray Int
n2
      Ptr a
vrPtr <- Int -> ContT () IO (Ptr a)
forall a r. Storable a => Int -> FortranIO r (Ptr a)
Call.allocaArray Int
n2
      Ptr CInt
mmPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
n
      Ptr CInt
mPtr <- FortranIO () (Ptr CInt)
forall a r. Storable a => FortranIO r (Ptr a)
Call.alloca
      IO () -> ContT () IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ String -> String -> (Ptr CInt -> IO ()) -> IO ()
withInfo String
errorCodeMsg String
"trevc" ((Ptr CInt -> IO ()) -> IO ()) -> (Ptr CInt -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$
         TREVC_ a
forall a. Floating a => TREVC_ a
trevc Ptr CChar
sidePtr Ptr CChar
howManyPtr Ptr Bool
forall a. Ptr a
selectPtr Int
n
            Ptr a
aPtr Ptr CInt
ldaPtr Ptr a
vlPtr Ptr CInt
ldaPtr Ptr a
vrPtr Ptr CInt
ldaPtr Ptr CInt
mmPtr Ptr CInt
mPtr
      Ptr CInt
sizePtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
triSize
      Ptr CInt
incPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
1
      IO () -> ContT () IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$ do
         Order -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Order -> Int -> Ptr a -> Ptr a -> IO ()
pack Order
ColumnMajor Int
n Ptr a
vrPtr Ptr a
vrpPtr
         Order -> Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Order -> Int -> Ptr a -> Ptr a -> IO ()
pack Order
RowMajor Int
n Ptr a
vlPtr Ptr a
vlpPtr
         Ptr CInt -> Ptr a -> Ptr CInt -> IO ()
forall a. Floating a => Ptr CInt -> Ptr a -> Ptr CInt -> IO ()
lacgv Ptr CInt
sizePtr Ptr a
vlpPtr Ptr CInt
incPtr


unpackZeroRowMajor :: Class.Floating a => Int -> Ptr a -> Ptr a -> IO ()
unpackZeroRowMajor :: Int -> Ptr a -> Ptr a -> IO ()
unpackZeroRowMajor Int
n Ptr a
packedPtr Ptr a
fullPtr = do
   a -> Order -> Int -> Ptr a -> IO ()
forall a. Floating a => a -> Order -> Int -> Ptr a -> IO ()
fillTriangle a
forall a. Floating a => a
zero Order
RowMajor Int
n Ptr a
fullPtr
   Int -> Ptr a -> Ptr a -> IO ()
forall a. Floating a => Int -> Ptr a -> Ptr a -> IO ()
unpackRowMajor Int
n Ptr a
packedPtr Ptr a
fullPtr

unpackRowMajor :: Class.Floating a => Int -> Ptr a -> Ptr a -> IO ()
unpackRowMajor :: Int -> Ptr a -> Ptr a -> IO ()
unpackRowMajor Int
n Ptr a
packedPtr Ptr a
fullPtr = ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> IO ()) -> ContT () IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
   Ptr CInt
incxPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
1
   Ptr CInt
incyPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
n
   IO () -> ContT () IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$
      [(Int, (Ptr a, Ptr a))]
-> (Ptr CInt -> (Ptr a, Ptr a) -> IO ()) -> IO ()
forall a. [(Int, a)] -> (Ptr CInt -> a -> IO ()) -> IO ()
forPointers (Int -> Ptr a -> Ptr a -> [(Int, (Ptr a, Ptr a))]
forall a.
Storable a =>
Int -> Ptr a -> Ptr a -> [(Int, (Ptr a, Ptr a))]
rowMajorPointers Int
n Ptr a
fullPtr Ptr a
packedPtr) ((Ptr CInt -> (Ptr a, Ptr a) -> IO ()) -> IO ())
-> (Ptr CInt -> (Ptr a, Ptr a) -> IO ()) -> IO ()
forall a b. (a -> b) -> a -> b
$
            \Ptr CInt
nPtr (Ptr a
dstPtr,Ptr a
srcPtr) ->
         Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO ()
forall a.
Floating a =>
Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> IO ()
BlasGen.copy Ptr CInt
nPtr Ptr a
srcPtr Ptr CInt
incxPtr Ptr a
dstPtr Ptr CInt
incyPtr


type TREVC_ a =
   Ptr CChar -> Ptr CChar -> Ptr Bool ->
   Int -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt -> Ptr a -> Ptr CInt ->
   Ptr CInt -> Ptr CInt -> Ptr CInt -> IO ()

newtype TREVC a = TREVC {TREVC a -> TREVC_ a
getTREVC :: TREVC_ a}

trevc :: Class.Floating a => TREVC_ a
trevc :: TREVC_ a
trevc =
   TREVC a -> TREVC_ a
forall a. TREVC a -> TREVC_ a
getTREVC (TREVC a -> TREVC_ a) -> TREVC a -> TREVC_ a
forall a b. (a -> b) -> a -> b
$
   TREVC Float
-> TREVC Double
-> TREVC (Complex Float)
-> TREVC (Complex Double)
-> TREVC a
forall a (f :: * -> *).
Floating a =>
f Float
-> f Double -> f (Complex Float) -> f (Complex Double) -> f a
Class.switchFloating
      (TREVC_ Float -> TREVC Float
forall a. TREVC_ a -> TREVC a
TREVC TREVC_ Float
forall a. Real a => TREVC_ a
trevcReal) (TREVC_ Double -> TREVC Double
forall a. TREVC_ a -> TREVC a
TREVC TREVC_ Double
forall a. Real a => TREVC_ a
trevcReal)
      (TREVC_ (Complex Float) -> TREVC (Complex Float)
forall a. TREVC_ a -> TREVC a
TREVC TREVC_ (Complex Float)
forall a. Real a => TREVC_ (Complex a)
trevcComplex) (TREVC_ (Complex Double) -> TREVC (Complex Double)
forall a. TREVC_ a -> TREVC a
TREVC TREVC_ (Complex Double)
forall a. Real a => TREVC_ (Complex a)
trevcComplex)

trevcReal :: Class.Real a => TREVC_ a
trevcReal :: TREVC_ a
trevcReal Ptr CChar
sidePtr Ptr CChar
howmnyPtr Ptr Bool
selectPtr Int
n
      Ptr a
tPtr Ptr CInt
ldtPtr Ptr a
vlPtr Ptr CInt
ldvlPtr Ptr a
vrPtr Ptr CInt
ldvrPtr Ptr CInt
mmPtr Ptr CInt
mPtr Ptr CInt
infoPtr =
   ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> IO ()) -> ContT () IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
      Ptr CInt
nPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
n
      Ptr a
workPtr <- Int -> FortranIO () (Ptr a)
forall a r. Storable a => Int -> FortranIO r (Ptr a)
Call.allocaArray (Int
3Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n)
      IO () -> ContT () IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$
         Ptr CChar
-> Ptr CChar
-> Ptr Bool
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr CInt
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> IO ()
forall a.
Real a =>
Ptr CChar
-> Ptr CChar
-> Ptr Bool
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> Ptr CInt
-> Ptr CInt
-> Ptr a
-> Ptr CInt
-> IO ()
LapackReal.trevc Ptr CChar
sidePtr Ptr CChar
howmnyPtr Ptr Bool
selectPtr Ptr CInt
nPtr
            Ptr a
tPtr Ptr CInt
ldtPtr Ptr a
vlPtr Ptr CInt
ldvlPtr Ptr a
vrPtr Ptr CInt
ldvrPtr Ptr CInt
mmPtr Ptr CInt
mPtr Ptr a
workPtr Ptr CInt
infoPtr

trevcComplex :: Class.Real a => TREVC_ (Complex a)
trevcComplex :: TREVC_ (Complex a)
trevcComplex Ptr CChar
sidePtr Ptr CChar
howmnyPtr Ptr Bool
selectPtr Int
n
      Ptr (Complex a)
tPtr Ptr CInt
ldtPtr Ptr (Complex a)
vlPtr Ptr CInt
ldvlPtr Ptr (Complex a)
vrPtr Ptr CInt
ldvrPtr Ptr CInt
mmPtr Ptr CInt
mPtr Ptr CInt
infoPtr =
   ContT () IO () -> IO ()
forall (m :: * -> *) r. Monad m => ContT r m r -> m r
evalContT (ContT () IO () -> IO ()) -> ContT () IO () -> IO ()
forall a b. (a -> b) -> a -> b
$ do
      Ptr CInt
nPtr <- Int -> FortranIO () (Ptr CInt)
forall r. Int -> FortranIO r (Ptr CInt)
Call.cint Int
n
      Ptr (Complex a)
workPtr <- Int -> FortranIO () (Ptr (Complex a))
forall a r. Storable a => Int -> FortranIO r (Ptr a)
Call.allocaArray (Int
2Int -> Int -> Int
forall a. Num a => a -> a -> a
*Int
n)
      Ptr a
rworkPtr <- Int -> FortranIO () (Ptr a)
forall a r. Storable a => Int -> FortranIO r (Ptr a)
Call.allocaArray Int
n
      IO () -> ContT () IO ()
forall (m :: * -> *) a. MonadIO m => IO a -> m a
liftIO (IO () -> ContT () IO ()) -> IO () -> ContT () IO ()
forall a b. (a -> b) -> a -> b
$
         Ptr CChar
-> Ptr CChar
-> Ptr Bool
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr CInt
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr a
-> Ptr CInt
-> IO ()
forall a.
Real a =>
Ptr CChar
-> Ptr CChar
-> Ptr Bool
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr CInt
-> Ptr CInt
-> Ptr CInt
-> Ptr (Complex a)
-> Ptr a
-> Ptr CInt
-> IO ()
LapackComplex.trevc Ptr CChar
sidePtr Ptr CChar
howmnyPtr Ptr Bool
selectPtr Ptr CInt
nPtr
            Ptr (Complex a)
tPtr Ptr CInt
ldtPtr Ptr (Complex a)
vlPtr Ptr CInt
ldvlPtr Ptr (Complex a)
vrPtr Ptr CInt
ldvrPtr Ptr CInt
mmPtr Ptr CInt
mPtr
            Ptr (Complex a)
workPtr Ptr a
rworkPtr Ptr CInt
infoPtr