
jetxee
By: a guest on
Jan 20th, 2009 | syntax:
Haskell | size: 0.77 KB | hits: 50 | expires: Never
-- one step of integration
stepEuler
:: (Floating a
) => a
-> [a
] -> [a
]
stepEuler mu u@(x:xs) = (applyBC . (diffused mu)) $! u -- strict evaluation of u
where
diffused mu (left:x:[]) = [] -- ignore outer points
diffused mu (left:x:right:xs) = -- integrate inner points
(x+mu*(left+right-2*x)) : diffused mu (x:right:xs)
applyBC inner
= inner `
seq` u' `
seq` l `
seq` r `
seq`
-- strict evaluation
(l ++ inner ++ r) -- boundary conditions
where u'
= [head u
] ++ inner
++ [last u
]
l = lbc u'
r = rbc u'
lbc = zeroflux mu -- left boundary
rbc
= (zeroflux mu
) . reverse -- right boundary