From cd3daf7e12fa2a8c775a1d6516049bbc7e44da32 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Thu, 24 Apr 2014 20:50:10 +0200 Subject: deprecate vjoin, dot and (<.>). Move (⋅) to Container MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- CHANGELOG | 26 ++++++-------------------- lib/Data/Packed/Vector.hs | 7 ++++++- lib/Numeric/Container.hs | 20 +++++++++++++++++++- lib/Numeric/LinearAlgebra/Util.hs | 16 +++++++++------- 4 files changed, 40 insertions(+), 29 deletions(-) diff --git a/CHANGELOG b/CHANGELOG index 393c52a..dea29a9 100644 --- a/CHANGELOG +++ b/CHANGELOG @@ -1,32 +1,18 @@ 0.16.0.0 -------- - * join renamed to vjoin - - * dot renamed to udot (unconjugated dot product) - * Removed (<.>) - - * added cdot, which conjugates the first input vector - * the operator (⋅) = cdot is available from Numeric.LinearAlgebra.Util + * join deprecated, use vjoin + * dot and (<.>) deprecated, use udot or (×) + + * added udot (unconjugated dot product) + * added (⋅) = cdot, which conjugates the first input vector * added a general multiplication operator (×) * improved build and konst * Plot functions moved to Numeric.LinearAlgebra.Util - * removed (!) (use (¦) instead) - -This version introduces a few backward incompatible changes but the code can be -updated very easily: - -join -> vjoin -dot -> udot -<.> -> × -import Graphics.Plot -> import Numeric.LinearAlgebra.Util - -The new contraction operator (×) performs matrix products, matrix-vector products, -unconjugated vector dot products, and scaling of vectors and matrices. - + * removed (!) (use (¦)) 0.15.2.0 -------- diff --git a/lib/Data/Packed/Vector.hs b/lib/Data/Packed/Vector.hs index a705ce4..f12031f 100644 --- a/lib/Data/Packed/Vector.hs +++ b/lib/Data/Packed/Vector.hs @@ -19,7 +19,7 @@ module Data.Packed.Vector ( Vector, fromList, (|>), toList, buildVector, dim, (@>), - subVector, takesV, vjoin, + subVector, takesV, vjoin, join, mapVector, mapVectorWithIndex, zipVector, zipVectorWith, unzipVector, unzipVectorWith, mapVectorM, mapVectorM_, mapVectorWithIndexM, mapVectorWithIndexM_, foldLoop, foldVector, foldVectorG, foldVectorWithIndex @@ -88,3 +88,8 @@ unzipVector :: (Storable a, Storable b, Storable (a,b)) => Vector (a,b) -> (Vect unzipVector = unzipVectorWith id ------------------------------------------------------------------- + +{-# DEPRECATED join "use vjoin or Data.Vector.concat" #-} +join :: Storable t => [Vector t] -> Vector t +join = vjoin + diff --git a/lib/Numeric/Container.hs b/lib/Numeric/Container.hs index 46c2903..aac8c10 100644 --- a/lib/Numeric/Container.hs +++ b/lib/Numeric/Container.hs @@ -38,7 +38,7 @@ module Numeric.Container ( Product(..), Contraction(..), optimiseMult, - mXm,mXv,vXm,Mul(..),LSDiv(..), cdot, + mXm,mXv,vXm,Mul(..),LSDiv(..), cdot, (⋅), dot, (<.>), outer, kronecker, -- * Random numbers RandDist(..), @@ -175,6 +175,13 @@ instance Container Matrix t => Contraction (Matrix t) t (Matrix t) where -------------------------------------------------------------------------------- +-- | dot product (0x22C5): @u ⋅ v = 'cdot' u v@ +(⋅) :: (Container Vector t, Product t) => Vector t -> Vector t -> t +infixl 7 ⋅ +u ⋅ v = cdot u v + +-------------------------------------------------------------------------------- + -- bidirectional type inference class Konst e d c | d -> c, c -> d where @@ -200,3 +207,14 @@ instance Container Matrix e => Build (Int,Int) (e -> e -> e) Matrix e where build = build' +-------------------------------------------------------------------------------- + +{-# DEPRECATED dot "use udot" #-} +dot :: Product e => Vector e -> Vector e -> e +dot = udot + +{-# DEPRECATED (<.>) "use udot or (×)" #-} +infixl 7 <.> +(<.>) :: Product e => Vector e -> Vector e -> e +(<.>) = udot + diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs index 2c77d3a..b38aeb2 100644 --- a/lib/Numeric/LinearAlgebra/Util.hs +++ b/lib/Numeric/LinearAlgebra/Util.hs @@ -23,7 +23,6 @@ module Numeric.LinearAlgebra.Util( (?), (¿), rand, randn, cross, - (⋅), norm, unitary, mt, @@ -86,7 +85,15 @@ rand = randm Uniform randn :: Int -> Int -> IO (Matrix Double) randn = randm Gaussian --- | create a real diagonal matrix from a list +{- | create a real diagonal matrix from a list + +>>> diagl [1,2,3] +(3><3) + [ 1.0, 0.0, 0.0 + , 0.0, 2.0, 0.0 + , 0.0, 0.0, 3.0 ] + +-} diagl :: [Double] -> Matrix Double diagl = diag . fromList @@ -164,11 +171,6 @@ size m = (rows m, cols m) mt :: Matrix Double -> Matrix Double mt = trans . inv --- | dot product (0x22C5): @u ⋅ v = 'cdot' u v@ -(⋅) :: (Container Vector t, Product t) => Vector t -> Vector t -> t -infixl 7 ⋅ -u ⋅ v = cdot u v - ---------------------------------------------------------------------- -- | Matrix of pairwise squared distances of row vectors -- cgit v1.2.3