summaryrefslogtreecommitdiff
path: root/packages/base/src/Numeric
diff options
context:
space:
mode:
authorAlberto Ruiz <aruiz@um.es>2015-04-15 09:17:30 +0200
committerAlberto Ruiz <aruiz@um.es>2015-04-15 09:17:30 +0200
commit27dceac51cbd904e06891e583d4b445e691efc8c (patch)
treec13ad1316f2e3ac220c8f4cad2004398b7fdc053 /packages/base/src/Numeric
parent7e266da987db30caeb91c86b9a7b8fd13d091213 (diff)
add unitary and pairwiseD2
Diffstat (limited to 'packages/base/src/Numeric')
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs2
-rw-r--r--packages/base/src/Numeric/LinearAlgebra/Util.hs10
2 files changed, 9 insertions, 3 deletions
diff --git a/packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs b/packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs
index 078a748..818b226 100644
--- a/packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs
@@ -10,6 +10,8 @@ Stability : provisional
10----------------------------------------------------------------------------- 10-----------------------------------------------------------------------------
11 11
12module Numeric.LinearAlgebra.HMatrix.Util( 12module Numeric.LinearAlgebra.HMatrix.Util(
13 unitary,
14 pairwiseD2,
13 -- * Tools for the Kronecker product 15 -- * Tools for the Kronecker product
14 -- 16 --
15 -- | (see A. Fusiello, A matter of notation: Several uses of the Kronecker product in 17 -- | (see A. Fusiello, A matter of notation: Several uses of the Kronecker product in
diff --git a/packages/base/src/Numeric/LinearAlgebra/Util.hs b/packages/base/src/Numeric/LinearAlgebra/Util.hs
index 043aa21..89202d3 100644
--- a/packages/base/src/Numeric/LinearAlgebra/Util.hs
+++ b/packages/base/src/Numeric/LinearAlgebra/Util.hs
@@ -227,10 +227,11 @@ infixl 9 ¿
227(¿)= flip extractColumns 227(¿)= flip extractColumns
228 228
229 229
230cross :: Vector Double -> Vector Double -> Vector Double 230cross :: Product t => Vector t -> Vector t -> Vector t
231-- ^ cross product (for three-element real vectors) 231-- ^ cross product (for three-element vectors)
232cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] 232cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3]
233 | otherwise = error $ "cross ("++show x++") ("++show y++")" 233 | otherwise = error $ "the cross product requires 3-element vectors (sizes given: "
234 ++show (dim x)++" and "++show (dim y)++")"
234 where 235 where
235 [x1,x2,x3] = toList x 236 [x1,x2,x3] = toList x
236 [y1,y2,y3] = toList y 237 [y1,y2,y3] = toList y
@@ -238,6 +239,9 @@ cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3]
238 z2 = x3*y1-x1*y3 239 z2 = x3*y1-x1*y3
239 z3 = x1*y2-x2*y1 240 z3 = x1*y2-x2*y1
240 241
242{-# SPECIALIZE cross :: Vector Double -> Vector Double -> Vector Double #-}
243{-# SPECIALIZE cross :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) #-}
244
241norm :: Vector Double -> Double 245norm :: Vector Double -> Double
242-- ^ 2-norm of real vector 246-- ^ 2-norm of real vector
243norm = pnorm PNorm2 247norm = pnorm PNorm2