X-Git-Url: http://gitweb.michael.orlitzky.com/?p=numerical-analysis.git;a=blobdiff_plain;f=src%2FLinear%2FMatrix.hs;h=c48f722265b19e3bd195ce5dc16e3ab44162d137;hp=d166e44367e626b9d87979a4b0e9ab7b2b24e7d9;hb=504257320e56784b914ff69e8efb22d6191e3372;hpb=edbf6900d50865b4b6278f13cd75d55df1289c90 diff --git a/src/Linear/Matrix.hs b/src/Linear/Matrix.hs index d166e44..c48f722 100644 --- a/src/Linear/Matrix.hs +++ b/src/Linear/Matrix.hs @@ -25,6 +25,7 @@ import Data.Vector.Fixed ( N5, S, Z, + generate, mk1, mk2, mk3, @@ -198,8 +199,6 @@ symmetric m = -- entries in the matrix. The i,j entry of the resulting matrix will -- have the value returned by lambda i j. -- --- TODO: Don't cheat with fromList. --- -- Examples: -- -- >>> let lambda i j = i + j @@ -208,13 +207,11 @@ symmetric m = -- construct :: forall m n a. (Arity m, Arity n) => (Int -> Int -> a) -> Mat m n a -construct lambda = Mat rows +construct lambda = Mat $ generate make_row where - -- The arity trick is used in Data.Vector.Fixed.length. - imax = (arity (undefined :: m)) - 1 - jmax = (arity (undefined :: n)) - 1 - row' i = V.fromList [ lambda i j | j <- [0..jmax] ] - rows = V.fromList [ row' i | i <- [0..imax] ] + make_row :: Int -> Vec n a + make_row i = generate (lambda i) + -- | Given a positive-definite matrix @m@, computes the