summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2007-06-22 10:21:15 +0000
committerAlberto Ruiz <aruiz@um.es>2007-06-22 10:21:15 +0000
commit989bdf7e88c13500bd1986dcde36f6cc4f467efb (patch)
treeb30ff0dd52e2b6c2adb1dfe8759d03234f65c684
parentaa14e6615533e7bd5e2b15acdc3ec76afbe1aac4 (diff)
reverting to the old signatures for aux C functions
-rw-r--r--examples/pru.hs53
-rw-r--r--lib/Data/Packed/Internal/Common.hs39
-rw-r--r--lib/Data/Packed/Internal/Matrix.hs25
-rw-r--r--lib/Data/Packed/Internal/Vector.hs9
-rw-r--r--lib/GSL/Fourier.hs2
-rw-r--r--lib/GSL/Minimization.hs6
-rw-r--r--lib/GSL/Polynomials.hs2
-rw-r--r--lib/GSL/Vector.hs14
-rw-r--r--lib/LAPACK.hs26
9 files changed, 136 insertions, 40 deletions
diff --git a/examples/pru.hs b/examples/pru.hs
index 4a5104b..fb33962 100644
--- a/examples/pru.hs
+++ b/examples/pru.hs
@@ -164,7 +164,7 @@ contractionF t1 t2 = contraction t1 n1 t2 n2
164 fn = snd . snd . head . dims 164 fn = snd . snd . head . dims
165 165
166 166
167dual vs = foldl' contractionF (leviCivita n) vs 167dualV vs = foldl' contractionF (leviCivita n) vs
168 where n = fst . head . dims . head $ vs 168 where n = fst . head . dims . head $ vs
169 169
170 170
@@ -175,4 +175,53 @@ dual2 = foldl' contractionF (leviCivita 3) [u,v,w]
175contract1b t (n1,n2) = contract1 t n1 n2 175contract1b t (n1,n2) = contract1 t n1 n2
176 176
177dual1' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v)) [("1","p'"),("2'","q''")]) (scalar (recip $ fact 2)) 177dual1' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v)) [("1","p'"),("2'","q''")]) (scalar (recip $ fact 2))
178dual2' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v /\ w)) [("1","p'"),("2'","q''"),("3'","r''")]) (scalar (recip $ fact 3)) \ No newline at end of file 178dual2' = prod (foldl' contract1b ((leviCivita 3) <*> (u /\ v /\ w)) [("1","p'"),("2'","q''"),("3'","r''")]) (scalar (recip $ fact 3))
179
180
181x1 = vector "p" [0,0,1]
182x2 = vector "q" [2,2,2]
183x3 = vector "r" [-3,-1,-1]
184x4 = vector "s" [12,0,3]
185
186raise (T d v) = T (map raise' d) v
187 where raise' (n,(Covariant,s)) = (n,(Contravariant,s))
188 raise' (n,(Contravariant,s)) = (n,(Covariant,s))
189
190dualMV t = prod (foldl' contract1b (lc <*> t) ds) (scalar (recip $ fromIntegral $ fact (length ds)))
191 where
192 lc = leviCivita n
193 nms1 = map (snd.snd) (dims lc)
194 nms2 = map ((++"'").snd.snd) (dims t)
195 ds = zip nms1 nms2
196 n = fst . head . dims $ t
197
198-- intersection of two lines :-)
199-- > raise $ dualMV $ raise $ dualMV (x1/\x2) /\ dualV [x3,x4]
200--(3'^[3]) [24.0,24.0,12.0]
201
202y1 = vector "p" [0,0,0,1]
203y2 = vector "q" [2,2,0,2]
204y3 = vector "r" [-3,-1,0,-1]
205y4 = vector "s" [12,0,0,3]
206
207-- why not in R^4?
208-- > raise $ dualMV $ raise $ dualMV (y1/\y2) /\ dualV [y3,y4]
209-- scalar 0.0
210-- it seems that the sum of ranks must be greater than n :(
211
212asBase r n = filter (\x-> (x==nub x && x==sort x)) $ sequence $ replicate r [1..n]
213
214partF t i = part t (name,i) where name = snd . snd . head . dims $ t
215
216--partL = foldl' partF
217
218niceAS t = filter ((/=0.0).fst) $ zip vals base
219 where vals = map ((`at` 0).ten.foldl' partF t) (map (map pred) base)
220 base = asBase r n
221 r = length (dims t)
222 n = fst . head . dims $ t
223
224z1 = vector "p" [0,0,0,1]
225z2 = vector "q" [1,0,0,1]
226z3 = vector "r" [0,1,0,1]
227z4 = vector "s" [0,0,1,1]
diff --git a/lib/Data/Packed/Internal/Common.hs b/lib/Data/Packed/Internal/Common.hs
index 91985f7..bdd7f34 100644
--- a/lib/Data/Packed/Internal/Common.hs
+++ b/lib/Data/Packed/Internal/Common.hs
@@ -86,3 +86,42 @@ scast = fromJust . cast
86{- | conversion of Haskell functions into function pointers that can be used in the C side 86{- | conversion of Haskell functions into function pointers that can be used in the C side
87-} 87-}
88foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double)) 88foreign import ccall "wrapper" mkfun:: (Double -> Ptr() -> Double) -> IO( FunPtr (Double -> Ptr() -> Double))
89
90---------------------------------------------------
91-- ugly, but my haddock version doesn't understand
92-- yet infix type constructors
93---------------------------------------------------
94---------- signatures of the C functions -------
95------------------------------------------------
96type PD = Ptr Double --
97type PC = Ptr (Complex Double) --
98type TV = Int -> PD -> IO Int --
99type TVV = Int -> PD -> TV --
100type TVVV = Int -> PD -> TVV --
101type TM = Int -> Int -> PD -> IO Int --
102type TMM = Int -> Int -> PD -> TM --
103type TMMM = Int -> Int -> PD -> TMM --
104type TVM = Int -> PD -> TM --
105type TVVM = Int -> PD -> TVM --
106type TMV = Int -> Int -> PD -> TV --
107type TMVM = Int -> Int -> PD -> TVM --
108type TMMVM = Int -> Int -> PD -> TMVM --
109type TCM = Int -> Int -> PC -> IO Int --
110type TCVCM = Int -> PC -> TCM --
111type TCMCVCM = Int -> Int -> PC -> TCVCM --
112type TMCMCVCM = Int -> Int -> PD -> TCMCVCM --
113type TCMCMCVCM = Int -> Int -> PC -> TCMCVCM --
114type TCMCM = Int -> Int -> PC -> TCM --
115type TVCM = Int -> PD -> TCM --
116type TCMVCM = Int -> Int -> PC -> TVCM --
117type TCMCMVCM = Int -> Int -> PC -> TCMVCM --
118type TCMCMCM = Int -> Int -> PC -> TCMCM --
119type TCV = Int -> PC -> IO Int --
120type TCVCV = Int -> PC -> TCV --
121type TCVCVCV = Int -> PC -> TCVCV --
122type TCMCV = Int -> Int -> PC -> TCV --
123type TVCV = Int -> PD -> TCV --
124type TCVM = Int -> PC -> TM --
125type TMCVM = Int -> Int -> PD -> TCVM --
126type TMMCVM = Int -> Int -> PD -> TMCVM --
127------------------------------------------------
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs
index fccf8bb..2925fc0 100644
--- a/lib/Data/Packed/Internal/Matrix.hs
+++ b/lib/Data/Packed/Internal/Matrix.hs
@@ -50,8 +50,9 @@ trans m = m { rows = cols m
50 } 50 }
51 51
52type Mt t s = Int -> Int -> Ptr t -> s 52type Mt t s = Int -> Int -> Ptr t -> s
53infixr 6 ::> 53-- not yet admitted by my haddock version
54type t ::> s = Mt t s 54-- infixr 6 ::>
55-- type t ::> s = Mt t s
55 56
56mat d m f = f (rows m) (cols m) (ptr (d m)) 57mat d m f = f (rows m) (cols m) (ptr (d m))
57 58
@@ -117,9 +118,9 @@ transdataAux fun c1 d c2 =
117 noneed = r1 == 1 || c1 == 1 118 noneed = r1 == 1 || c1 == 1
118 119
119foreign import ccall safe "aux.h transR" 120foreign import ccall safe "aux.h transR"
120 ctransR :: Double ::> Double ::> IO Int 121 ctransR :: TMM -- Double ::> Double ::> IO Int
121foreign import ccall safe "aux.h transC" 122foreign import ccall safe "aux.h transC"
122 ctransC :: Complex Double ::> Complex Double ::> IO Int 123 ctransC :: TCMCM -- Complex Double ::> Complex Double ::> IO Int
123 124
124transdata :: Field a => Int -> Vector a -> Int -> Vector a 125transdata :: Field a => Int -> Vector a -> Int -> Vector a
125transdata c1 d c2 | isReal baseOf d = scast $ transdataR c1 (scast d) c2 126transdata c1 d c2 | isReal baseOf d = scast $ transdataR c1 (scast d) c2
@@ -170,10 +171,16 @@ multiplyAux order fun a b = unsafePerformIO $ do
170 return r 171 return r
171 172
172foreign import ccall safe "aux.h multiplyR" 173foreign import ccall safe "aux.h multiplyR"
173 cmultiplyR :: Int -> Double ::> (Int -> Double ::> (Double ::> IO Int)) 174 cmultiplyR :: Int -> Int -> Int -> Ptr Double
175 -> Int -> Int -> Int -> Ptr Double
176 -> Int -> Int -> Ptr Double
177 -> IO Int
174 178
175foreign import ccall safe "aux.h multiplyC" 179foreign import ccall safe "aux.h multiplyC"
176 cmultiplyC :: Int -> Complex Double ::> (Int -> Complex Double ::> (Complex Double ::> IO Int)) 180 cmultiplyC :: Int -> Int -> Int -> Ptr (Complex Double)
181 -> Int -> Int -> Int -> Ptr (Complex Double)
182 -> Int -> Int -> Ptr (Complex Double)
183 -> IO Int
177 184
178multiply :: (Num a, Field a) => MatrixOrder -> Matrix a -> Matrix a -> Matrix a 185multiply :: (Num a, Field a) => MatrixOrder -> Matrix a -> Matrix a -> Matrix a
179multiply RowMajor a b = multiplyD RowMajor a b 186multiply RowMajor a b = multiplyD RowMajor a b
@@ -206,7 +213,7 @@ subMatrixR (r0,c0) (rt,ct) x = unsafePerformIO $ do
206 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat cdat r // check "subMatrixR" [dat r] 213 c_submatrixR r0 (r0+rt-1) c0 (c0+ct-1) // mat cdat x // mat cdat r // check "subMatrixR" [dat r]
207 return r 214 return r
208foreign import ccall "aux.h submatrixR" 215foreign import ccall "aux.h submatrixR"
209 c_submatrixR :: Int -> Int -> Int -> Int -> Double ::> Double ::> IO Int 216 c_submatrixR :: Int -> Int -> Int -> Int -> TMM
210 217
211-- | extraction of a submatrix of a complex matrix 218-- | extraction of a submatrix of a complex matrix
212subMatrixC :: (Int,Int) -- ^ (r0,c0) starting position 219subMatrixC :: (Int,Int) -- ^ (r0,c0) starting position
@@ -239,12 +246,12 @@ diagAux fun msg (v@V {dim = n}) = unsafePerformIO $ do
239-- | diagonal matrix from a real vector 246-- | diagonal matrix from a real vector
240diagR :: Vector Double -> Matrix Double 247diagR :: Vector Double -> Matrix Double
241diagR = diagAux c_diagR "diagR" 248diagR = diagAux c_diagR "diagR"
242foreign import ccall "aux.h diagR" c_diagR :: Double :> Double ::> IO Int 249foreign import ccall "aux.h diagR" c_diagR :: TVM
243 250
244-- | diagonal matrix from a real vector 251-- | diagonal matrix from a real vector
245diagC :: Vector (Complex Double) -> Matrix (Complex Double) 252diagC :: Vector (Complex Double) -> Matrix (Complex Double)
246diagC = diagAux c_diagC "diagC" 253diagC = diagAux c_diagC "diagC"
247foreign import ccall "aux.h diagC" c_diagC :: (Complex Double) :> (Complex Double) ::> IO Int 254foreign import ccall "aux.h diagC" c_diagC :: TCVCM
248 255
249-- | diagonal matrix from a vector 256-- | diagonal matrix from a vector
250diag :: (Num a, Field a) => Vector a -> Matrix a 257diag :: (Num a, Field a) => Vector a -> Matrix a
diff --git a/lib/Data/Packed/Internal/Vector.hs b/lib/Data/Packed/Internal/Vector.hs
index 125df1e..8848062 100644
--- a/lib/Data/Packed/Internal/Vector.hs
+++ b/lib/Data/Packed/Internal/Vector.hs
@@ -21,8 +21,9 @@ import Complex
21import Control.Monad(when) 21import Control.Monad(when)
22 22
23type Vc t s = Int -> Ptr t -> s 23type Vc t s = Int -> Ptr t -> s
24infixr 5 :> 24-- not yet admitted by my haddock version
25type t :> s = Vc t s 25-- infixr 5 :>
26-- type t :> s = Vc t s
26 27
27vec :: Vector t -> (Vc t s) -> s 28vec :: Vector t -> (Vc t s) -> s
28vec v f = f (dim v) (ptr v) 29vec v f = f (dim v) (ptr v)
@@ -118,10 +119,10 @@ constantAux fun n x = unsafePerformIO $ do
118 return v 119 return v
119 120
120foreign import ccall safe "aux.h constantR" 121foreign import ccall safe "aux.h constantR"
121 cconstantR :: Ptr Double -> Double :> IO Int 122 cconstantR :: Ptr Double -> TV -- Double :> IO Int
122 123
123foreign import ccall safe "aux.h constantC" 124foreign import ccall safe "aux.h constantC"
124 cconstantC :: Ptr (Complex Double) -> Complex Double :> IO Int 125 cconstantC :: Ptr (Complex Double) -> TCV -- Complex Double :> IO Int
125 126
126constant :: Field a => Int -> a -> Vector a 127constant :: Field a => Int -> a -> Vector a
127constant n x | isReal id x = scast $ constantR n (scast x) 128constant n x | isReal id x = scast $ constantR n (scast x)
diff --git a/lib/GSL/Fourier.hs b/lib/GSL/Fourier.hs
index c8c79f0..bf6cd60 100644
--- a/lib/GSL/Fourier.hs
+++ b/lib/GSL/Fourier.hs
@@ -29,7 +29,7 @@ genfft code v = unsafePerformIO $ do
29 c_fft code // vec v // vec r // check "fft" [v] 29 c_fft code // vec v // vec r // check "fft" [v]
30 return r 30 return r
31 31
32foreign import ccall "gsl-aux.h fft" c_fft :: Int -> Complex Double :> Complex Double :> IO Int 32foreign import ccall "gsl-aux.h fft" c_fft :: Int -> TCVCV -- Complex Double :> Complex Double :> IO Int
33 33
34 34
35{- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave. 35{- | Fast 1D Fourier transform of a 'Vector' @(@'Complex' 'Double'@)@ using /gsl_fft_complex_forward/. It uses the same scaling conventions as GNU Octave.
diff --git a/lib/GSL/Minimization.hs b/lib/GSL/Minimization.hs
index bc228a7..32b266f 100644
--- a/lib/GSL/Minimization.hs
+++ b/lib/GSL/Minimization.hs
@@ -97,7 +97,7 @@ minimizeNMSimplex f xi sz tol maxit = unsafePerformIO $ do
97 97
98foreign import ccall "gsl-aux.h minimize" 98foreign import ccall "gsl-aux.h minimize"
99 c_minimizeNMSimplex:: FunPtr (Int -> Ptr Double -> Double) -> Double -> Int 99 c_minimizeNMSimplex:: FunPtr (Int -> Ptr Double -> Double) -> Double -> Int
100 -> Double :> Double :> Double ::> IO Int 100 -> TVVM -- Double :> Double :> Double ::> IO Int
101 101
102---------------------------------------------------------------------------------- 102----------------------------------------------------------------------------------
103 103
@@ -164,8 +164,8 @@ minimizeConjugateGradient istep minimpar tol maxit f df xi = unsafePerformIO $ d
164foreign import ccall "gsl-aux.h minimizeWithDeriv" 164foreign import ccall "gsl-aux.h minimizeWithDeriv"
165 c_minimizeConjugateGradient :: FunPtr (Int -> Ptr Double -> Double) 165 c_minimizeConjugateGradient :: FunPtr (Int -> Ptr Double -> Double)
166 -> FunPtr (Int -> Ptr Double -> Ptr Double -> IO ()) 166 -> FunPtr (Int -> Ptr Double -> Ptr Double -> IO ())
167 -> Double -> Double -> Double -> Int 167 -> Double -> Double -> Double -> Int
168 -> Double :> Double ::> IO Int 168 -> TVM -- Double :> Double ::> IO Int
169 169
170--------------------------------------------------------------------- 170---------------------------------------------------------------------
171iv :: (Vector Double -> Double) -> (Int -> Ptr Double -> Double) 171iv :: (Vector Double -> Double) -> (Int -> Ptr Double -> Double)
diff --git a/lib/GSL/Polynomials.hs b/lib/GSL/Polynomials.hs
index d7db9a3..365c74e 100644
--- a/lib/GSL/Polynomials.hs
+++ b/lib/GSL/Polynomials.hs
@@ -51,4 +51,4 @@ polySolve' v | dim v > 1 = unsafePerformIO $ do
51 return r 51 return r
52 | otherwise = error "polySolve on a polynomial of degree zero" 52 | otherwise = error "polySolve on a polynomial of degree zero"
53 53
54foreign import ccall "gsl-aux.h polySolve" c_polySolve:: Double :> Complex Double :> IO Int 54foreign import ccall "gsl-aux.h polySolve" c_polySolve:: TVCV -- Double :> Complex Double :> IO Int
diff --git a/lib/GSL/Vector.hs b/lib/GSL/Vector.hs
index 3225139..fc80c16 100644
--- a/lib/GSL/Vector.hs
+++ b/lib/GSL/Vector.hs
@@ -122,7 +122,7 @@ toScalarR :: FunCodeS -> Vector Double -> Double
122toScalarR oper = toScalarAux c_toScalarR (fromEnum oper) 122toScalarR oper = toScalarAux c_toScalarR (fromEnum oper)
123 123
124foreign import ccall safe "gsl-aux.h toScalarR" 124foreign import ccall safe "gsl-aux.h toScalarR"
125 c_toScalarR :: Int -> Double :> Double :> IO Int 125 c_toScalarR :: Int -> TVV -- Double :> Double :> IO Int
126 126
127------------------------------------------------------------------ 127------------------------------------------------------------------
128 128
@@ -131,14 +131,14 @@ vectorMapR :: FunCodeV -> Vector Double -> Vector Double
131vectorMapR = vectorMapAux c_vectorMapR 131vectorMapR = vectorMapAux c_vectorMapR
132 132
133foreign import ccall safe "gsl-aux.h mapR" 133foreign import ccall safe "gsl-aux.h mapR"
134 c_vectorMapR :: Int -> Double :> Double :> IO Int 134 c_vectorMapR :: Int -> TVV -- Double :> Double :> IO Int
135 135
136-- | map of complex vectors with given function 136-- | map of complex vectors with given function
137vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double) 137vectorMapC :: FunCodeV -> Vector (Complex Double) -> Vector (Complex Double)
138vectorMapC oper = vectorMapAux c_vectorMapC (fromEnum oper) 138vectorMapC oper = vectorMapAux c_vectorMapC (fromEnum oper)
139 139
140foreign import ccall safe "gsl-aux.h mapC" 140foreign import ccall safe "gsl-aux.h mapC"
141 c_vectorMapC :: Int -> Complex Double :> Complex Double :> IO Int 141 c_vectorMapC :: Int -> TCVCV -- Complex Double :> Complex Double :> IO Int
142 142
143------------------------------------------------------------------- 143-------------------------------------------------------------------
144 144
@@ -147,14 +147,14 @@ vectorMapValR :: FunCodeSV -> Double -> Vector Double -> Vector Double
147vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromEnum oper) 147vectorMapValR oper = vectorMapValAux c_vectorMapValR (fromEnum oper)
148 148
149foreign import ccall safe "gsl-aux.h mapValR" 149foreign import ccall safe "gsl-aux.h mapValR"
150 c_vectorMapValR :: Int -> Ptr Double -> Double :> Double :> IO Int 150 c_vectorMapValR :: Int -> Ptr Double -> TVV -- Double :> Double :> IO Int
151 151
152-- | map of complex vectors with given function 152-- | map of complex vectors with given function
153vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double) 153vectorMapValC :: FunCodeSV -> Complex Double -> Vector (Complex Double) -> Vector (Complex Double)
154vectorMapValC = vectorMapValAux c_vectorMapValC 154vectorMapValC = vectorMapValAux c_vectorMapValC
155 155
156foreign import ccall safe "gsl-aux.h mapValC" 156foreign import ccall safe "gsl-aux.h mapValC"
157 c_vectorMapValC :: Int -> Ptr (Complex Double) -> Complex Double :> Complex Double :> IO Int 157 c_vectorMapValC :: Int -> Ptr (Complex Double) -> TCVCV -- Complex Double :> Complex Double :> IO Int
158 158
159------------------------------------------------------------------- 159-------------------------------------------------------------------
160 160
@@ -163,13 +163,13 @@ vectorZipR :: FunCodeVV -> Vector Double -> Vector Double -> Vector Double
163vectorZipR = vectorZipAux c_vectorZipR 163vectorZipR = vectorZipAux c_vectorZipR
164 164
165foreign import ccall safe "gsl-aux.h zipR" 165foreign import ccall safe "gsl-aux.h zipR"
166 c_vectorZipR :: Int -> Double :> Double :> Double :> IO Int 166 c_vectorZipR :: Int -> TVVV -- Double :> Double :> Double :> IO Int
167 167
168-- | elementwise operation on complex vectors 168-- | elementwise operation on complex vectors
169vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) 169vectorZipC :: FunCodeVV -> Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double)
170vectorZipC = vectorZipAux c_vectorZipC 170vectorZipC = vectorZipAux c_vectorZipC
171 171
172foreign import ccall safe "gsl-aux.h zipC" 172foreign import ccall safe "gsl-aux.h zipC"
173 c_vectorZipC :: Int -> Complex Double :> Complex Double :> Complex Double :> IO Int 173 c_vectorZipC :: Int -> TCVCVCV -- Complex Double :> Complex Double :> Complex Double :> IO Int
174 174
175 175
diff --git a/lib/LAPACK.hs b/lib/LAPACK.hs
index 1531cfb..dc9eda1 100644
--- a/lib/LAPACK.hs
+++ b/lib/LAPACK.hs
@@ -32,7 +32,7 @@ import Foreign
32----------------------------------------------------------------------------- 32-----------------------------------------------------------------------------
33-- dgesvd 33-- dgesvd
34foreign import ccall "LAPACK/lapack-aux.h svd_l_R" 34foreign import ccall "LAPACK/lapack-aux.h svd_l_R"
35 dgesvd :: Double ::> Double ::> (Double :> Double ::> IO Int) 35 dgesvd :: TMMVM -- Double ::> Double ::> (Double :> Double ::> IO Int)
36 36
37-- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix. 37-- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix.
38-- 38--
@@ -50,7 +50,7 @@ svdR' x@M {rows = r, cols = c} = unsafePerformIO $ do
50----------------------------------------------------------------------------- 50-----------------------------------------------------------------------------
51-- dgesdd 51-- dgesdd
52foreign import ccall "LAPACK/lapack-aux.h svd_l_Rdd" 52foreign import ccall "LAPACK/lapack-aux.h svd_l_Rdd"
53 dgesdd :: Double ::> Double ::> (Double :> Double ::> IO Int) 53 dgesdd :: TMMVM --Double ::> Double ::> (Double :> Double ::> IO Int)
54 54
55-- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix. 55-- | Wrapper for LAPACK's /dgesvd/, which computes the full svd decomposition of a real matrix.
56-- 56--
@@ -68,7 +68,7 @@ svdRdd' x@M {rows = r, cols = c} = unsafePerformIO $ do
68----------------------------------------------------------------------------- 68-----------------------------------------------------------------------------
69-- zgesvd 69-- zgesvd
70foreign import ccall "LAPACK/lapack-aux.h svd_l_C" 70foreign import ccall "LAPACK/lapack-aux.h svd_l_C"
71 zgesvd :: (Complex Double) ::> (Complex Double) ::> (Double :> (Complex Double) ::> IO Int) 71 zgesvd :: TCMCMVCM -- (Complex Double) ::> (Complex Double) ::> (Double :> (Complex Double) ::> IO Int)
72 72
73-- | Wrapper for LAPACK's /zgesvd/, which computes the full svd decomposition of a complex matrix. 73-- | Wrapper for LAPACK's /zgesvd/, which computes the full svd decomposition of a complex matrix.
74-- 74--
@@ -87,7 +87,7 @@ svdC' x@M {rows = r, cols = c} = unsafePerformIO $ do
87----------------------------------------------------------------------------- 87-----------------------------------------------------------------------------
88-- zgeev 88-- zgeev
89foreign import ccall "LAPACK/lapack-aux.h eig_l_C" 89foreign import ccall "LAPACK/lapack-aux.h eig_l_C"
90 zgeev :: (Complex Double) ::> (Complex Double) ::> ((Complex Double) :> (Complex Double) ::> IO Int) 90 zgeev :: TCMCMCVCM -- (Complex Double) ::> (Complex Double) ::> ((Complex Double) :> (Complex Double) ::> IO Int)
91 91
92-- | Wrapper for LAPACK's /zgeev/, which computes the eigenvalues and right eigenvectors of a general complex matrix: 92-- | Wrapper for LAPACK's /zgeev/, which computes the eigenvalues and right eigenvectors of a general complex matrix:
93-- 93--
@@ -108,7 +108,7 @@ eigC (m@M {rows = r})
108----------------------------------------------------------------------------- 108-----------------------------------------------------------------------------
109-- dgeev 109-- dgeev
110foreign import ccall "LAPACK/lapack-aux.h eig_l_R" 110foreign import ccall "LAPACK/lapack-aux.h eig_l_R"
111 dgeev :: Double ::> Double ::> ((Complex Double) :> Double ::> IO Int) 111 dgeev :: TMMCVM -- Double ::> Double ::> ((Complex Double) :> Double ::> IO Int)
112 112
113-- | Wrapper for LAPACK's /dgeev/, which computes the eigenvalues and right eigenvectors of a general real matrix: 113-- | Wrapper for LAPACK's /dgeev/, which computes the eigenvalues and right eigenvectors of a general real matrix:
114-- 114--
@@ -144,7 +144,7 @@ scale r v = fromList [r] `outer` v
144----------------------------------------------------------------------------- 144-----------------------------------------------------------------------------
145-- dsyev 145-- dsyev
146foreign import ccall "LAPACK/lapack-aux.h eig_l_S" 146foreign import ccall "LAPACK/lapack-aux.h eig_l_S"
147 dsyev :: Double ::> (Double :> Double ::> IO Int) 147 dsyev :: TMVM -- Double ::> (Double :> Double ::> IO Int)
148 148
149-- | Wrapper for LAPACK's /dsyev/, which computes the eigenvalues and right eigenvectors of a symmetric real matrix: 149-- | Wrapper for LAPACK's /dsyev/, which computes the eigenvalues and right eigenvectors of a symmetric real matrix:
150-- 150--
@@ -168,7 +168,7 @@ eigS' (m@M {rows = r})
168----------------------------------------------------------------------------- 168-----------------------------------------------------------------------------
169-- zheev 169-- zheev
170foreign import ccall "LAPACK/lapack-aux.h eig_l_H" 170foreign import ccall "LAPACK/lapack-aux.h eig_l_H"
171 zheev :: (Complex Double) ::> (Double :> (Complex Double) ::> IO Int) 171 zheev :: TCMVCM -- (Complex Double) ::> (Double :> (Complex Double) ::> IO Int)
172 172
173-- | Wrapper for LAPACK's /zheev/, which computes the eigenvalues and right eigenvectors of a hermitian complex matrix: 173-- | Wrapper for LAPACK's /zheev/, which computes the eigenvalues and right eigenvectors of a hermitian complex matrix:
174-- 174--
@@ -192,7 +192,7 @@ eigH' (m@M {rows = r})
192----------------------------------------------------------------------------- 192-----------------------------------------------------------------------------
193-- dgesv 193-- dgesv
194foreign import ccall "LAPACK/lapack-aux.h linearSolveR_l" 194foreign import ccall "LAPACK/lapack-aux.h linearSolveR_l"
195 dgesv :: Double ::> Double ::> Double ::> IO Int 195 dgesv :: TMMM -- Double ::> Double ::> Double ::> IO Int
196 196
197-- | Wrapper for LAPACK's /dgesv/, which solves a general real linear system (for several right-hand sides) internally using the lu decomposition. 197-- | Wrapper for LAPACK's /dgesv/, which solves a general real linear system (for several right-hand sides) internally using the lu decomposition.
198linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double 198linearSolveR :: Matrix Double -> Matrix Double -> Matrix Double
@@ -206,7 +206,7 @@ linearSolveR a@(M {rows = n1, cols = n2}) b@(M {rows = r, cols = c})
206----------------------------------------------------------------------------- 206-----------------------------------------------------------------------------
207-- zgesv 207-- zgesv
208foreign import ccall "LAPACK/lapack-aux.h linearSolveC_l" 208foreign import ccall "LAPACK/lapack-aux.h linearSolveC_l"
209 zgesv :: (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int 209 zgesv :: TCMCMCM -- (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int
210 210
211-- | Wrapper for LAPACK's /zgesv/, which solves a general complex linear system (for several right-hand sides) internally using the lu decomposition. 211-- | Wrapper for LAPACK's /zgesv/, which solves a general complex linear system (for several right-hand sides) internally using the lu decomposition.
212linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) 212linearSolveC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
@@ -220,7 +220,7 @@ linearSolveC a@(M {rows = n1, cols = n2}) b@(M {rows = r, cols = c})
220----------------------------------------------------------------------------------- 220-----------------------------------------------------------------------------------
221-- dgels 221-- dgels
222foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l" 222foreign import ccall "LAPACK/lapack-aux.h linearSolveLSR_l"
223 dgels :: Double ::> Double ::> Double ::> IO Int 223 dgels :: TMMM -- Double ::> Double ::> Double ::> IO Int
224 224
225-- | Wrapper for LAPACK's /dgels/, which obtains the least squared error solution of an overconstrained real linear system or the minimum norm solution of an underdetermined system, for several right-hand sides. For rank deficient systems use 'linearSolveSVDR'. 225-- | Wrapper for LAPACK's /dgels/, which obtains the least squared error solution of an overconstrained real linear system or the minimum norm solution of an underdetermined system, for several right-hand sides. For rank deficient systems use 'linearSolveSVDR'.
226linearSolveLSR :: Matrix Double -> Matrix Double -> Matrix Double 226linearSolveLSR :: Matrix Double -> Matrix Double -> Matrix Double
@@ -234,7 +234,7 @@ linearSolveLSR_l a@(M {rows = m, cols = n}) b@(M {cols = nrhs}) = unsafePerformI
234----------------------------------------------------------------------------------- 234-----------------------------------------------------------------------------------
235-- zgels 235-- zgels
236foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l" 236foreign import ccall "LAPACK/lapack-aux.h linearSolveLSC_l"
237 zgels :: (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int 237 zgels :: TCMCMCM -- (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int
238 238
239-- | Wrapper for LAPACK's /zgels/, which obtains the least squared error solution of an overconstrained complex linear system or the minimum norm solution of an underdetermined system, for several right-hand sides. For rank deficient systems use 'linearSolveSVDC'. 239-- | Wrapper for LAPACK's /zgels/, which obtains the least squared error solution of an overconstrained complex linear system or the minimum norm solution of an underdetermined system, for several right-hand sides. For rank deficient systems use 'linearSolveSVDC'.
240linearSolveLSC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double) 240linearSolveLSC :: Matrix (Complex Double) -> Matrix (Complex Double) -> Matrix (Complex Double)
@@ -248,7 +248,7 @@ linearSolveLSC_l a@(M {rows = m, cols = n}) b@(M {cols = nrhs}) = unsafePerformI
248----------------------------------------------------------------------------------- 248-----------------------------------------------------------------------------------
249-- dgelss 249-- dgelss
250foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l" 250foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDR_l"
251 dgelss :: Double -> Double ::> Double ::> Double ::> IO Int 251 dgelss :: Double -> TMMM -- Double ::> Double ::> Double ::> IO Int
252 252
253-- | Wrapper for LAPACK's /dgelss/, which obtains the minimum norm solution to a real linear least squares problem Ax=B using the svd, for several right-hand sides. Admits rank deficient systems but it is slower than 'linearSolveLSR'. The effective rank of A is determined by treating as zero those singular valures which are less than rcond times the largest singular value. If rcond == Nothing machine precision is used. 253-- | Wrapper for LAPACK's /dgelss/, which obtains the minimum norm solution to a real linear least squares problem Ax=B using the svd, for several right-hand sides. Admits rank deficient systems but it is slower than 'linearSolveLSR'. The effective rank of A is determined by treating as zero those singular valures which are less than rcond times the largest singular value. If rcond == Nothing machine precision is used.
254linearSolveSVDR :: Maybe Double -- ^ rcond 254linearSolveSVDR :: Maybe Double -- ^ rcond
@@ -266,7 +266,7 @@ linearSolveSVDR_l rcond a@(M {rows = m, cols = n}) b@(M {cols = nrhs}) = unsafeP
266----------------------------------------------------------------------------------- 266-----------------------------------------------------------------------------------
267-- zgelss 267-- zgelss
268foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l" 268foreign import ccall "LAPACK/lapack-aux.h linearSolveSVDC_l"
269 zgelss :: Double -> (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int 269 zgelss :: Double -> TCMCMCM -- (Complex Double) ::> (Complex Double) ::> (Complex Double) ::> IO Int
270 270
271-- | Wrapper for LAPACK's /zgelss/, which obtains the minimum norm solution to a complex linear least squares problem Ax=B using the svd, for several right-hand sides. Admits rank deficient systems but it is slower than 'linearSolveLSC'. The effective rank of A is determined by treating as zero those singular valures which are less than rcond times the largest singular value. If rcond == Nothing machine precision is used. 271-- | Wrapper for LAPACK's /zgelss/, which obtains the minimum norm solution to a complex linear least squares problem Ax=B using the svd, for several right-hand sides. Admits rank deficient systems but it is slower than 'linearSolveLSC'. The effective rank of A is determined by treating as zero those singular valures which are less than rcond times the largest singular value. If rcond == Nothing machine precision is used.
272linearSolveSVDC :: Maybe Double -- ^ rcond 272linearSolveSVDC :: Maybe Double -- ^ rcond