Files
mercury/benchmarks/progs/pic/haskell/ElecField.hs
Paul Bone ea06fd8cde Add the benchmarks directory into the main Mercury repository.
This was a seperate repository in CVS and so it missed the conversion.

benchmarks/
    As above.
2013-01-04 12:13:53 +11:00

31 lines
710 B
Haskell

--
-- Patricia Fasel
-- Los Alamos National Laboratory
-- 1990 August
--
module ElecField (elecField) where
import PicType
import Consts
import Data.Array
-- Phase III: Calculate electric fields
-- the x and y components of the electric field are approximated
-- by the first partial difference in each dimension
elecField :: Phi -> Electric
elecField phi =
(array ((0,0), (n,n))
([((i,j) , (phi!(i-1,j) - phi!(i,j)))
| i <- [1..n], j <- [0..n]]++
[((0,j) , (phi!(n,j) - phi!(0,j)))
| j <- [0..n]]),
array ((0,0), (n,n))
([((i,j) , (phi!(i,j+1) - phi!(i,j)))
| i <- [0..n], j <- [0..(n-1)]]++
[((i,n) , (phi!(i,0) - phi!(i,n)) )
| i <- [0..n]]))
where
n = nCell-1