]> gitweb.michael.orlitzky.com - numerical-analysis.git/blobdiff - src/Linear/System.hs
Replace the whole Matrix implementation with something a little better.
[numerical-analysis.git] / src / Linear / System.hs
index e0fdf1ce8e15d58ccc32314c7d08135b2f517279..58d8d78e7a6fe866751109a1c1dfb1610eeeb728 100644 (file)
@@ -5,7 +5,7 @@
 module Linear.System
 where
 
-import Data.Vector.Fixed (Dim, N1, Vector)
+import Data.Vector.Fixed (Arity, N1)
 
 import Linear.Matrix
 
@@ -13,7 +13,6 @@ import NumericPrelude hiding ((*), abs)
 import qualified NumericPrelude as NP ((*))
 import qualified Algebra.Field as Field
 
-import Debug.Trace (trace, traceShow)
 
 -- | Solve the system m' * x = b', where m' is upper-triangular. Will
 --   probably crash if m' is non-singular. The result is the vector x.
@@ -21,27 +20,21 @@ import Debug.Trace (trace, traceShow)
 --   Examples:
 --
 --   >>> let identity = fromList [[1,0,0],[0,1,0],[0,0,1]] :: Mat3 Double
---   >>> let b = vec3d (1,2,3)
+--   >>> let b = vec3d (1, 2, 3::Double)
 --   >>> forward_substitute identity b
 --   ((1.0),(2.0),(3.0))
 --   >>> (forward_substitute identity b) == b
 --   True
 --
 --   >>> let m = fromList [[1,0],[1,1]] :: Mat2 Double
---   >>> let b = vec2d (1,1)
+--   >>> let b = vec2d (1, 1::Double)
 --   >>> forward_substitute m b
 --   ((1.0),(0.0))
 --
-forward_substitute :: forall a v w z.
-                      (Show a, Field.C a,
-                       Vector z a,
-                       Vector w (z a),
-                       Vector w a,
-                       Dim z ~ N1,
-                       v ~ w)
-                   => Mat v w a
-                   -> Mat w z a
-                   -> Mat w z a
+forward_substitute :: forall a m. (Field.C a, Arity m)
+                   => Mat m m a
+                   -> Mat m N1 a
+                   -> Mat m N1 a
 forward_substitute m' b' = x'
   where
     x' = construct lambda
@@ -72,22 +65,16 @@ forward_substitute m' b' = x'
 --   Examples:
 --
 --   >>> let identity = fromList [[1,0,0],[0,1,0],[0,0,1]] :: Mat3 Double
---   >>> let b = vec3d (1,2,3)
+--   >>> let b = vec3d (1, 2, 3::Double)
 --   >>> backward_substitute identity b
 --   ((1.0),(2.0),(3.0))
 --   >>> (backward_substitute identity b) == b
 --   True
 --
-backward_substitute :: (Show a, Field.C a,
-                        Vector z a,
-                        Vector v (w a),
-                        Vector w (z a),
-                        Vector w a,
-                        Dim z ~ N1,
-                        v ~ w)
-                    => Mat v w a
-                    -> Mat w z a
-                    -> Mat w z a
+backward_substitute :: (Field.C a, Arity m)
+                    => Mat m m a
+                    -> Mat m N1 a
+                    -> Mat m N1 a
 backward_substitute m b =
   forward_substitute (transpose m) b