From 2cd153900a470f174fc65f597f9c8a40d0700ab9 Mon Sep 17 00:00:00 2001 From: Alberto Ruiz Date: Tue, 21 May 2013 13:47:17 +0200 Subject: size, unitary, mt --- lib/Numeric/LinearAlgebra/Util.hs | 23 +++++++++++++++++++++-- 1 file changed, 21 insertions(+), 2 deletions(-) diff --git a/lib/Numeric/LinearAlgebra/Util.hs b/lib/Numeric/LinearAlgebra/Util.hs index c4e4007..d92ed76 100644 --- a/lib/Numeric/LinearAlgebra/Util.hs +++ b/lib/Numeric/LinearAlgebra/Util.hs @@ -12,8 +12,9 @@ Stability : provisional ----------------------------------------------------------------------------- module Numeric.LinearAlgebra.Util( - -- * Convenience functions for real elements - disp, + + -- * Convenience functions + size, disp, zeros, ones, diagl, row, @@ -22,6 +23,8 @@ module Numeric.LinearAlgebra.Util( rand, randn, cross, norm, + unitary, + mt, -- * Convolution -- ** 1D corr, conv, corrMin, @@ -120,6 +123,22 @@ norm :: Vector Double -> Double -- ^ 2-norm of real vector norm = pnorm PNorm2 + +-- | Obtains a vector in the same direction with 2-norm=1 +unitary :: Vector Double -> Vector Double +unitary v = v / scalar (norm v) + +-- | (rows &&& cols) +size :: Matrix t -> (Int, Int) +size m = (rows m, cols m) + +-- | trans . inv +mt :: Matrix Double -> Matrix Double +mt = trans . inv + +---------------------------------------------------------------------- + + -------------------------------------------------------------------------------- vec :: Element t => Matrix t -> Vector t -- cgit v1.2.3