]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/Linear/QR.hs
Require a matrix to be nonempty if we're going to QR factorize it.
[numerical-analysis.git] / src / Linear / QR.hs
index 13782c4fa9073728bfdf5d4a0de8b4a2788a67e4..4c1c56446f836c348b1b7e65ad138fb650dd9ed3 100644 (file)
@@ -140,7 +140,8 @@ givens_rotator i j xi xj =
 --   True
 --
 qr :: forall m n a. (Arity m, Arity n, Eq a, Algebraic.C a, Ring.C a)
-   => Mat m n a -> (Mat m m a, Mat m n a)
+   => Mat (S m) (S n) a
+   -> (Mat (S m) (S m) a, Mat (S m) (S n) a)
 qr matrix =
   ifoldl col_function initial_qr columns
   where
@@ -155,14 +156,14 @@ qr matrix =
       ifoldl (f col_idx) (q,r) col
 
     -- | Process the entries in a column, doing basically the same
-    --   thing as col_dunction does. It updates the QR factorization,
+    --   thing as col_function does. It updates the QR factorization,
     --   maybe, and returns the current one.
     f col_idx (q,r) idx _ -- ignore the current element
       | idx <= col_idx = (q,r) -- leave it alone
       | otherwise = (q*rotator, (transpose rotator)*r)
           where
             y = r !!! (idx, col_idx)
-            rotator :: Mat m m a
+            rotator :: Mat (S m) (S m) a
             rotator = givens_rotator col_idx idx (r !!! (col_idx, col_idx)) y
 
 
@@ -231,7 +232,7 @@ eigenvalues iterations matrix
 --   Examples:
 --
 --   >>> import Linear.Matrix ( Col2, Col3, Mat2, Mat3 )
---   >>> import Linear.Matrix ( column', frobenius_norm, fromList )
+--   >>> import Linear.Matrix ( column, frobenius_norm, fromList )
 --   >>> import Linear.Matrix ( identity_matrix, vec3d )
 --   >>> import Normed ( Normed(..) )
 --
@@ -253,11 +254,11 @@ eigenvalues iterations matrix
 --   >>> let v1  = (1 / (norm v1') :: Double) *> v1'
 --   >>> let v2' = vec3d (-4, -2, 5) :: Col3 Double
 --   >>> let v2  = (1 / (norm v2') :: Double) *> v2'
---   >>> frobenius_norm ((column' vecs 0) - v0) < 1e-12
+--   >>> frobenius_norm ((column vecs 0) - v0) < 1e-12
 --   True
---   >>> frobenius_norm ((column' vecs 1) - v1) < 1e-12
+--   >>> frobenius_norm ((column vecs 1) - v1) < 1e-12
 --   True
---   >>> frobenius_norm ((column' vecs 2) - v2) < 1e-12
+--   >>> frobenius_norm ((column vecs 2) - v2) < 1e-12
 --   True
 --
 eigenvectors_symmetric :: forall m a. (Arity m, Algebraic.C a, Eq a)