   Go backward to References
Go up to Top

# Determinant

This appendix contains two more versions of the determinant function from the linear equation solver described in Section *. The version on the left is the original sequential version. That on the right is a slightly cleaned-up version of the directly-parallel code originally written. Compared with the strategic version presented earlier, the directly parallel version is both lower-level and more obscure.

 Sequential Version: ```sum l_par where l_par = map determine1 [jLo..jHi] determine1 j = (if pivot > 0 then sign*pivot*det' else 0) where sign = if (even (j-jLo)) then 1 else -1 pivot = (head mat) !! (j-1) mat' = SqMatrixC ((iLo,jLo),(iHi-1,jHi-1)) (map (newLine j) (tail mat)) det' = determinant mat' ``` Direct Parallel Version: ```sum l_par where l_par = do_it_from_to jLo do_it_from_to j | j>jHi = [] | otherwise = fx `par` (fx:rest) where sign = if (even (j-jLo)) then 1 else -1 mat' = SqMatrixC ((iLo,jLo),(iHi-1,jHi-1)) (parMap (newLine j) (tail mat)) pivot = (head mat) !! (j-1) det' = mat' `seq` determinant mat' x = case pivot of 0 -> 0 _ -> sign*pivot*det' fx = sign `par` if pivot>0 then det' `par` x else x rest = do_it_from_to (j+1) ```

{trinder,hwloidl,simonpj}@dcs.gla.ac.uk, kh@dcs.st-and.ac.uk   