How can I efficiently compute the determinant of a square diagonal matrix? In this case, the determinant is simply the product of each element in the diagonal. I can think of a couple options that might work:

- I could store the diagonal of the matrix as a vector and apply a
`reduce`

operation to it (would I have to write my own`reduce`

?). I think that one could implement a “poor man’s reduce” using`map`

. - I could implement my own class,
`DiagonalMatrix`

, and add a`determinant`

function to it.