summaryrefslogtreecommitdiff
path: root/packages/base
diff options
context:
space:
mode:
authorKevin Slagle <kjslag@gmail.com>2016-10-18 23:42:09 -0700
committerKevin Slagle <kjslag@gmail.com>2016-10-18 23:42:09 -0700
commitd71833a6737eae7d2485eeabcec1c5dfbe9d46de (patch)
tree7d6aafcad7d77e7817467aca573b113fff777fa1 /packages/base
parent341ced1daf7ceb3d3b4c0d54e37eb37d7db51408 (diff)
document norm functions and fix compactSVDTol documentation
Diffstat (limited to 'packages/base')
-rw-r--r--packages/base/src/Internal/Algorithms.hs2
-rw-r--r--packages/base/src/Internal/Util.hs4
2 files changed, 4 insertions, 2 deletions
diff --git a/packages/base/src/Internal/Algorithms.hs b/packages/base/src/Internal/Algorithms.hs
index 1ccd3a2..7ead5b4 100644
--- a/packages/base/src/Internal/Algorithms.hs
+++ b/packages/base/src/Internal/Algorithms.hs
@@ -294,7 +294,7 @@ fromList [35.18264833189422,1.4769076999800903]
294compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t) 294compactSVD :: Field t => Matrix t -> (Matrix t, Vector Double, Matrix t)
295compactSVD = compactSVDTol 1 295compactSVD = compactSVDTol 1
296 296
297-- | @compactSVDTol r@ is similar to 'compactSVDTol', but uses tolerance @tol=r*g*eps*(max rows cols)@ to distinguish nonzero singular values, where @g@ is the greatest singular value. 297-- | @compactSVDTol r@ is similar to 'compactSVD', but uses tolerance @tol=r*g*eps*(max rows cols)@ to distinguish nonzero singular values, where @g@ is the greatest singular value.
298compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t) 298compactSVDTol :: Field t => Double -> Matrix t -> (Matrix t, Vector Double, Matrix t)
299compactSVDTol r m = (u', subVector 0 d s, v') where 299compactSVDTol r m = (u', subVector 0 d s, v') where
300 (u,s,v) = thinSVD m 300 (u,s,v) = thinSVD m
diff --git a/packages/base/src/Internal/Util.hs b/packages/base/src/Internal/Util.hs
index cf42961..7f52a9c 100644
--- a/packages/base/src/Internal/Util.hs
+++ b/packages/base/src/Internal/Util.hs
@@ -255,6 +255,7 @@ norm :: Vector Double -> Double
255-- ^ 2-norm of real vector 255-- ^ 2-norm of real vector
256norm = pnorm PNorm2 256norm = pnorm PNorm2
257 257
258-- | p-norm for vectors, operator norm for matrices
258class Normed a 259class Normed a
259 where 260 where
260 norm_0 :: a -> R 261 norm_0 :: a -> R
@@ -319,10 +320,11 @@ instance Normed (Vector (Complex Float))
319 norm_2 = norm_2 . double 320 norm_2 = norm_2 . double
320 norm_Inf = norm_Inf . double 321 norm_Inf = norm_Inf . double
321 322
322 323-- | Frobenius norm (Schatten p-norm with p=2)
323norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R 324norm_Frob :: (Normed (Vector t), Element t) => Matrix t -> R
324norm_Frob = norm_2 . flatten 325norm_Frob = norm_2 . flatten
325 326
327-- | Sum of singular values (Schatten p-norm with p=1)
326norm_nuclear :: Field t => Matrix t -> R 328norm_nuclear :: Field t => Matrix t -> R
327norm_nuclear = sumElements . singularValues 329norm_nuclear = sumElements . singularValues
328 330