doNTimes :: SeismicData -> Array U DIM1 Float -> Int -> Int -> Array U DIM2 Float
doNTimes !sd !pv !t !ctr | ctr == t = apf sd
                         | otherwise = doNTimes (seismic (ppf sd) apfw (vel sd) ) pv t $ ctr+1
  where
    {-# INLINE apfw #-}
    apfw = addPulse (apf sd) $ pv `R.unsafeIndex` (Z:. ctr)
    {-# INLINE addPulse #-}
    addPulse apff pulse = fromUnboxed (Z:. ySize :. xSize) ((toUnboxed apff) `V.unsafeUpd`
                              [(posV, val (toUnboxed apff) + pulse)])
    ex = extent $ apf sd
    ySize = (head $ listOfShape ex)
    xSize = (last $ listOfShape ex)
    posV = (ySize * (ySize `div` 2)) + (xSize `div` 2) -- index is correct
    val axs = axs `V.unsafeIndex` posV -- extract the value of apf at posV

-- the real calculation
doNTimes :: SeismicData -> Array U DIM1 Float -> Int -> Int -> Array U DIM2 Float
doNTimes !sd !pv !t !ctr | ctr == t = apf sd
                         | otherwise = doNTimes (seismic (ppf sd) apfw (vel sd) ) pv t $ ctr+1
  where
    {-# INLINE apfw #-}
    apfw = addPulse (apf sd) $ pv `R.unsafeIndex` (Z:. ctr)
    {-# INLINE addPulse #-}
    addPulse apff pulse = fromUnboxed (Z:. ySize :. xSize) ((toUnboxed apff) `V.unsafeUpd`
                              [(posV, val (toUnboxed apff) + pulse)])
    ex = extent $ apf sd
    ySize = (head $ listOfShape ex)
    xSize = (last $ listOfShape ex)
    posV = (ySize * (ySize `div` 2)) + (xSize `div` 2) -- index is correct
    val axs = axs `V.unsafeIndex` posV -- extract the value of apf at posV

-- the real calculation
doNTimes !sd !pv !t !ctr | ctr == t = apf sd
                         | otherwise = doNTimes (seismic (ppf sd) apfw (vel sd) ) pv t $ ctr+1
  where
    {-# INLINE apfw #-}
    apfw = addPulse (apf sd) $ pv `R.unsafeIndex` (Z:. ctr)
    {-# INLINE addPulse #-}
    addPulse apff pulse = fromUnboxed (Z:. ySize :. xSize) ((toUnboxed apff) `V.unsafeUpd`
                              [(posV, val (toUnboxed apff) + pulse)])
    ex = extent $ apf sd
    ySize = (head $ listOfShape ex)
    xSize = (last $ listOfShape ex)
    posV = (ySize * (ySize `div` 2)) + (xSize `div` 2) -- index is correct
    val axs = axs `V.unsafeIndex` posV -- extract the value of apf at posV

-- the real calculation