+-- | Compute the Frobenius norm of a matrix. This essentially treats
+-- the matrix as one long vector containing all of its entries (in
+-- any order, it doesn't matter).
+--
+-- Examples:
+--
+-- >>> let m = fromList [[1, 2, 3],[4,5,6],[7,8,9]] :: Mat3 Double
+-- >>> frobenius_norm m == sqrt 285
+-- True
+--
+-- >>> let m = fromList [[1, -1, 1],[-1,1,-1],[1,-1,1]] :: Mat3 Double
+-- >>> frobenius_norm m == 3
+-- True
+--
+frobenius_norm :: (Algebraic.C a, Ring.C a) => Mat m n a -> a
+frobenius_norm (Mat rows) =
+ sqrt $ element_sum $ V.map row_sum rows
+ where
+ -- | Square and add up the entries of a row.
+ row_sum = element_sum . V.map (^2)