From 1cf0ec95f1a8f9893a643723d24a10422231f250 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 22 May 2013 10:11:00 +0200 Subject: operators for extraction of rows and columns, alternative concatenation --- lib/Numeric/LinearAlgebra/Util.hs | 19 ++++++++++++++++++- 1 file changed, 18 insertions(+), 1 deletion(-) (limited to 'lib/Numeric/LinearAlgebra') 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( diagl, row, col, - (&),(!), (#), + (&),(!), (¦), (#), + (?),(¿), rand, randn, cross, norm, @@ -99,6 +100,11 @@ infixl 3 ! (!) :: Matrix Double -> Matrix Double -> Matrix Double a ! b = fromBlocks [[a,b]] +-- | (00A6) horizontal concatenation of real matrices +infixl 3 ¦ +(¦) :: Matrix Double -> Matrix Double -> Matrix Double +a ¦ b = fromBlocks [[a,b]] + -- | vertical concatenation of real matrices (#) :: Matrix Double -> Matrix Double -> Matrix Double infixl 2 # @@ -112,6 +118,17 @@ row = asRow . fromList col :: [Double] -> Matrix Double col = asColumn . fromList +-- | extract selected rows +infixl 9 ? +(?) :: Element t => Matrix t -> [Int] -> Matrix t +(?) = flip extractRows + +-- | (00BF) extract selected columns +infixl 9 ¿ +(¿) :: Element t => Matrix t -> [Int] -> Matrix t +m ¿ ks = trans . extractRows ks . trans $ m + + cross :: Vector Double -> Vector Double -> Vector Double -- ^ cross product (for three-element real vectors) cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] -- cgit v1.2.3