diff options
-rw-r--r-- | lib/Numeric/LinearAlgebra/Util.hs | 23 |
1 files 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 | |||
12 | ----------------------------------------------------------------------------- | 12 | ----------------------------------------------------------------------------- |
13 | 13 | ||
14 | module Numeric.LinearAlgebra.Util( | 14 | module Numeric.LinearAlgebra.Util( |
15 | -- * Convenience functions for real elements | 15 | |
16 | disp, | 16 | -- * Convenience functions |
17 | size, disp, | ||
17 | zeros, ones, | 18 | zeros, ones, |
18 | diagl, | 19 | diagl, |
19 | row, | 20 | row, |
@@ -22,6 +23,8 @@ module Numeric.LinearAlgebra.Util( | |||
22 | rand, randn, | 23 | rand, randn, |
23 | cross, | 24 | cross, |
24 | norm, | 25 | norm, |
26 | unitary, | ||
27 | mt, | ||
25 | -- * Convolution | 28 | -- * Convolution |
26 | -- ** 1D | 29 | -- ** 1D |
27 | corr, conv, corrMin, | 30 | corr, conv, corrMin, |
@@ -120,6 +123,22 @@ norm :: Vector Double -> Double | |||
120 | -- ^ 2-norm of real vector | 123 | -- ^ 2-norm of real vector |
121 | norm = pnorm PNorm2 | 124 | norm = pnorm PNorm2 |
122 | 125 | ||
126 | |||
127 | -- | Obtains a vector in the same direction with 2-norm=1 | ||
128 | unitary :: Vector Double -> Vector Double | ||
129 | unitary v = v / scalar (norm v) | ||
130 | |||
131 | -- | (rows &&& cols) | ||
132 | size :: Matrix t -> (Int, Int) | ||
133 | size m = (rows m, cols m) | ||
134 | |||
135 | -- | trans . inv | ||
136 | mt :: Matrix Double -> Matrix Double | ||
137 | mt = trans . inv | ||
138 | |||
139 | ---------------------------------------------------------------------- | ||
140 | |||
141 | |||
123 | -------------------------------------------------------------------------------- | 142 | -------------------------------------------------------------------------------- |
124 | 143 | ||
125 | vec :: Element t => Matrix t -> Vector t | 144 | vec :: Element t => Matrix t -> Vector t |