summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric/LinearAlgebra/Util.hs
diff options
context:
space:
mode:
Diffstat (limited to 'packages/base/src/Numeric/LinearAlgebra/Util.hs')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs48
1 files changed, 1 insertions, 47 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index 89202d3..370ca27 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -16,7 +16,6 @@ Stability : provisional
16 16
17-} 17-}
18----------------------------------------------------------------------------- 18-----------------------------------------------------------------------------
19{-# OPTIONS_HADDOCK hide #-}
20 19
21module Numeric.LinearAlgebra.Util( 20module Numeric.LinearAlgebra.Util(
22 21
@@ -53,18 +52,7 @@ module Numeric.LinearAlgebra.Util(
53 -- ** 1D 52 -- ** 1D
54 corr, conv, corrMin, 53 corr, conv, corrMin,
55 -- ** 2D 54 -- ** 2D
56 corr2, conv2, separable, 55 corr2, conv2, separable
57 -- * Tools for the Kronecker product
58 --
59 -- | (see A. Fusiello, A matter of notation: Several uses of the Kronecker product in
60 -- 3d computer vision, Pattern Recognition Letters 28 (15) (2007) 2127-2132)
61
62 --
63 -- | @`vec` (a \<> x \<> b) == ('trans' b ` 'kronecker' ` a) \<> 'vec' x@
64 vec,
65 vech,
66 dup,
67 vtrans
68) where 56) where
69 57
70import Data.Packed.Numeric 58import Data.Packed.Numeric
@@ -407,40 +395,6 @@ null1sym = last . toColumns . snd . eigSH'
407 395
408-------------------------------------------------------------------------------- 396--------------------------------------------------------------------------------
409 397
410vec :: Element t => Matrix t -> Vector t
411-- ^ stacking of columns
412vec = flatten . trans
413
414
415vech :: Element t => Matrix t -> Vector t
416-- ^ half-vectorization (of the lower triangular part)
417vech m = vjoin . zipWith f [0..] . toColumns $ m
418 where
419 f k v = subVector k (dim v - k) v
420
421
422dup :: (Num t, Num (Vector t), Element t) => Int -> Matrix t
423-- ^ duplication matrix (@'dup' k \<> 'vech' m == 'vec' m@, for symmetric m of 'dim' k)
424dup k = trans $ fromRows $ map f es
425 where
426 rs = zip [0..] (toRows (ident (k^(2::Int))))
427 es = [(i,j) | j <- [0..k-1], i <- [0..k-1], i>=j ]
428 f (i,j) | i == j = g (k*j + i)
429 | otherwise = g (k*j + i) + g (k*i + j)
430 g j = v
431 where
432 Just v = lookup j rs
433
434
435vtrans :: Element t => Int -> Matrix t -> Matrix t
436-- ^ generalized \"vector\" transposition: @'vtrans' 1 == 'trans'@, and @'vtrans' ('rows' m) m == 'asColumn' ('vec' m)@
437vtrans p m | r == 0 = fromBlocks . map (map asColumn . takesV (replicate q p)) . toColumns $ m
438 | otherwise = error $ "vtrans " ++ show p ++ " of matrix with " ++ show (rows m) ++ " rows"
439 where
440 (q,r) = divMod (rows m) p
441
442--------------------------------------------------------------------------------
443
444infixl 0 ~!~ 398infixl 0 ~!~
445c ~!~ msg = when c (error msg) 399c ~!~ msg = when c (error msg)
446 400