diff options
author | Alberto Ruiz <aruiz@um.es> | 2008-11-05 11:02:45 +0000 |
---|---|---|
committer | Alberto Ruiz <aruiz@um.es> | 2008-11-05 11:02:45 +0000 |
commit | 21e13ae0a13befb5cb8feb7c52bcd4b4e4cda953 (patch) | |
tree | dc41066b6fd545d76a6fa3114f1d5cf3473a642c /lib/Data/Packed/Internal/Matrix.hs | |
parent | 02805ad64715373347b34bac2f75cbb866563ba2 (diff) |
diag using ST
Diffstat (limited to 'lib/Data/Packed/Internal/Matrix.hs')
-rw-r--r-- | lib/Data/Packed/Internal/Matrix.hs | 25 |
1 files changed, 0 insertions, 25 deletions
diff --git a/lib/Data/Packed/Internal/Matrix.hs b/lib/Data/Packed/Internal/Matrix.hs index 63f0a8d..51fb6f8 100644 --- a/lib/Data/Packed/Internal/Matrix.hs +++ b/lib/Data/Packed/Internal/Matrix.hs | |||
@@ -213,19 +213,16 @@ class (Storable a, Floating a) => Element a where | |||
213 | subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position | 213 | subMatrixD :: (Int,Int) -- ^ (r0,c0) starting position |
214 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix | 214 | -> (Int,Int) -- ^ (rt,ct) dimensions of submatrix |
215 | -> Matrix a -> Matrix a | 215 | -> Matrix a -> Matrix a |
216 | diagD :: Vector a -> Matrix a | ||
217 | 216 | ||
218 | instance Element Double where | 217 | instance Element Double where |
219 | constantD = constantR | 218 | constantD = constantR |
220 | transdata = transdataR | 219 | transdata = transdataR |
221 | subMatrixD = subMatrixR | 220 | subMatrixD = subMatrixR |
222 | diagD = diagR | ||
223 | 221 | ||
224 | instance Element (Complex Double) where | 222 | instance Element (Complex Double) where |
225 | constantD = constantC | 223 | constantD = constantC |
226 | transdata = transdataC | 224 | transdata = transdataC |
227 | subMatrixD = subMatrixC | 225 | subMatrixD = subMatrixC |
228 | diagD = diagC | ||
229 | 226 | ||
230 | ------------------------------------------------------------------ | 227 | ------------------------------------------------------------------ |
231 | 228 | ||
@@ -287,28 +284,6 @@ subMatrix :: Element a | |||
287 | -> Matrix a -- ^ result | 284 | -> Matrix a -- ^ result |
288 | subMatrix = subMatrixD | 285 | subMatrix = subMatrixD |
289 | 286 | ||
290 | |||
291 | --------------------------------------------------------------------- | ||
292 | |||
293 | diagAux fun msg (v@V {dim = n}) = unsafePerformIO $ do | ||
294 | m <- createMatrix RowMajor n n | ||
295 | app2 fun vec v mat m msg | ||
296 | return m | ||
297 | |||
298 | -- | diagonal matrix from a real vector | ||
299 | diagR :: Vector Double -> Matrix Double | ||
300 | diagR = diagAux c_diagR "diagR" | ||
301 | foreign import ccall "auxi.h diagR" c_diagR :: TVM | ||
302 | |||
303 | -- | diagonal matrix from a real vector | ||
304 | diagC :: Vector (Complex Double) -> Matrix (Complex Double) | ||
305 | diagC = diagAux c_diagC "diagC" | ||
306 | foreign import ccall "auxi.h diagC" c_diagC :: TCVCM | ||
307 | |||
308 | -- | creates a square matrix with the given diagonal | ||
309 | diag :: Element a => Vector a -> Matrix a | ||
310 | diag = diagD | ||
311 | |||
312 | ------------------------------------------------------------------------ | 287 | ------------------------------------------------------------------------ |
313 | 288 | ||
314 | constantAux fun x n = unsafePerformIO $ do | 289 | constantAux fun x n = unsafePerformIO $ do |