From: Michael Orlitzky Date: Wed, 19 Feb 2014 01:22:12 +0000 (-0500) Subject: Use the element_sum2 function to sum the terms in Gaussian integration instead of... X-Git-Url: https://gitweb.michael.orlitzky.com/?a=commitdiff_plain;h=762a87a1bd7bc628ebf12263fb21566ab3aeb86f;p=numerical-analysis.git Use the element_sum2 function to sum the terms in Gaussian integration instead of the incorrect 1-norm. --- diff --git a/src/Integration/Gaussian.hs b/src/Integration/Gaussian.hs index 6eb46f6..554dadc 100644 --- a/src/Integration/Gaussian.hs +++ b/src/Integration/Gaussian.hs @@ -25,6 +25,7 @@ import Linear.Matrix ( Col10, Mat(..), construct, + element_sum2, fromList, identity_matrix, map2, @@ -32,7 +33,6 @@ import Linear.Matrix ( transpose, zipwith2 ) import Linear.QR ( eigenvectors_symmetric ) -import Normed ( Normed(..) ) -- | Compute the Jacobi matrix for the Legendre polynomials over @@ -187,9 +187,6 @@ gaussian f = -- type level so this function couldn't just compute e.g. @n@ of -- them for you). -- --- The class constraints on @a@ could be loosened significantly if --- we implemented column sum outside of the 1-norm. --- -- Examples: -- -- >>> import Linear.Matrix ( Col5 ) @@ -202,7 +199,7 @@ gaussian f = -- True -- gaussian' :: forall m a. - (Arity m, Absolute.C a, Algebraic.C a, ToRational.C a, Ring.C a) + (Arity m, ToRational.C a, Ring.C a) => (a -> a) -- ^ The function @f@ to integrate. -> Col (S m) a -- ^ Column matrix of nodes -> Col (S m) a -- ^ Column matrix of weights @@ -210,7 +207,7 @@ gaussian' :: forall m a. gaussian' f nodes weights = -- The one norm is just the sum of the entries, which is what we -- want. - norm_p (1::Int) weighted_values + element_sum2 weighted_values where function_values = map2 f nodes weighted_values = zipwith2 (*) weights function_values