summaryrefslogtreecommitdiff
path: root/lib/Numeric/LinearAlgebra
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2013-05-22 10:11:00 +0200
committerAlberto Ruiz <aruiz@um.es>2013-05-22 10:11:00 +0200
commit1cf0ec95f1a8f9893a643723d24a10422231f250 (patch)
treed7e791da3cb9083da0ccc1d59b37a7069f8a8f04 /lib/Numeric/LinearAlgebra
parent66fea11dddad6f58e4fb1297b17b0b5ce1d6e8db (diff)
operators for extraction of rows and columns, alternative concatenation
Diffstat (limited to 'lib/Numeric/LinearAlgebra')
-rw-r--r--lib/Numeric/LinearAlgebra/Util.hs19
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
100a ! b = fromBlocks [[a,b]] 101a ! b = fromBlocks [[a,b]]
101 102
103-- | (00A6) horizontal concatenation of real matrices
104infixl 3 ¦
105(¦) :: Matrix Double -> Matrix Double -> Matrix Double
106a ¦ 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
104infixl 2 # 110infixl 2 #
@@ -112,6 +118,17 @@ row = asRow . fromList
112col :: [Double] -> Matrix Double 118col :: [Double] -> Matrix Double
113col = asColumn . fromList 119col = asColumn . fromList
114 120
121-- | extract selected rows
122infixl 9 ?
123(?) :: Element t => Matrix t -> [Int] -> Matrix t
124(?) = flip extractRows
125
126-- | (00BF) extract selected columns
127infixl 9 ¿
128(¿) :: Element t => Matrix t -> [Int] -> Matrix t
129m ¿ ks = trans . extractRows ks . trans $ m
130
131
115cross :: Vector Double -> Vector Double -> Vector Double 132cross :: Vector Double -> Vector Double -> Vector Double
116-- ^ cross product (for three-element real vectors) 133-- ^ cross product (for three-element real vectors)
117cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] 134cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3]