diff options
-rw-r--r-- | lib/Numeric/LinearAlgebra/Util.hs | 19 |
1 files changed, 18 insertions, 1 deletions
diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs index 3e4f6a9..c4b7776 100644 --- a/lib/Numeric/LinearAlgebra/Util.hs +++ b/lib/Numeric/LinearAlgebra/Util.hs | |||
@@ -19,7 +19,8 @@ module Numeric.LinearAlgebra.Util( | |||
19 | diagl, | 19 | diagl, |
20 | row, | 20 | row, |
21 | col, | 21 | col, |
22 | (&),(!), (#), | 22 | (&),(!), (¦), (#), |
23 | (?),(¿), | ||
23 | rand, randn, | 24 | rand, randn, |
24 | cross, | 25 | cross, |
25 | norm, | 26 | norm, |
@@ -99,6 +100,11 @@ infixl 3 ! | |||
99 | (!) :: Matrix Double -> Matrix Double -> Matrix Double | 100 | (!) :: Matrix Double -> Matrix Double -> Matrix Double |
100 | a ! b = fromBlocks [[a,b]] | 101 | a ! b = fromBlocks [[a,b]] |
101 | 102 | ||
103 | -- | (00A6) horizontal concatenation of real matrices | ||
104 | infixl 3 ¦ | ||
105 | (¦) :: Matrix Double -> Matrix Double -> Matrix Double | ||
106 | a ¦ b = fromBlocks [[a,b]] | ||
107 | |||
102 | -- | vertical concatenation of real matrices | 108 | -- | vertical concatenation of real matrices |
103 | (#) :: Matrix Double -> Matrix Double -> Matrix Double | 109 | (#) :: Matrix Double -> Matrix Double -> Matrix Double |
104 | infixl 2 # | 110 | infixl 2 # |
@@ -112,6 +118,17 @@ row = asRow . fromList | |||
112 | col :: [Double] -> Matrix Double | 118 | col :: [Double] -> Matrix Double |
113 | col = asColumn . fromList | 119 | col = asColumn . fromList |
114 | 120 | ||
121 | -- | extract selected rows | ||
122 | infixl 9 ? | ||
123 | (?) :: Element t => Matrix t -> [Int] -> Matrix t | ||
124 | (?) = flip extractRows | ||
125 | |||
126 | -- | (00BF) extract selected columns | ||
127 | infixl 9 ¿ | ||
128 | (¿) :: Element t => Matrix t -> [Int] -> Matrix t | ||
129 | m ¿ ks = trans . extractRows ks . trans $ m | ||
130 | |||
131 | |||
115 | cross :: Vector Double -> Vector Double -> Vector Double | 132 | cross :: Vector Double -> Vector Double -> Vector Double |
116 | -- ^ cross product (for three-element real vectors) | 133 | -- ^ cross product (for three-element real vectors) |
117 | cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] | 134 | cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] |