From 27dceac51cbd904e06891e583d4b445e691efc8c Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Wed, 15 Apr 2015 09:17:30 +0200 Subject: add unitary and pairwiseD2 --- packages/base/src/Numeric/LinearAlgebra/HMatrix/Util.hs | 2 ++ packages/base/src/Numeric/LinearAlgebra/Util.hs | 10 +++++++--- 2 files changed, 9 insertions(+), 3 deletions(-) (limited to 'packages') 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 ----------------------------------------------------------------------------- module Numeric.LinearAlgebra.HMatrix.Util( + unitary, + pairwiseD2, -- * Tools for the Kronecker product -- -- | (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 ¿ (¿)= flip extractColumns -cross :: Vector Double -> Vector Double -> Vector Double --- ^ cross product (for three-element real vectors) +cross :: Product t => Vector t -> Vector t -> Vector t +-- ^ cross product (for three-element vectors) cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] - | otherwise = error $ "cross ("++show x++") ("++show y++")" + | otherwise = error $ "the cross product requires 3-element vectors (sizes given: " + ++show (dim x)++" and "++show (dim y)++")" where [x1,x2,x3] = toList x [y1,y2,y3] = toList y @@ -238,6 +239,9 @@ cross x y | dim x == 3 && dim y == 3 = fromList [z1,z2,z3] z2 = x3*y1-x1*y3 z3 = x1*y2-x2*y1 +{-# SPECIALIZE cross :: Vector Double -> Vector Double -> Vector Double #-} +{-# SPECIALIZE cross :: Vector (Complex Double) -> Vector (Complex Double) -> Vector (Complex Double) #-} + norm :: Vector Double -> Double -- ^ 2-norm of real vector norm = pnorm PNorm2 -- cgit v1.2.3