A few fixes

I was surprised to find that the `mapMatrixWithIndex` functions passed the indices as the same type as the element. I'm not sure of the motivation for this, but this seems inappropriate for many uses of these functions. I've changed these to omit the conversion `Int -> a`.

Also, previously `mapMatrixWithIndex` was implemented using `mapVectorWithIndexM` which stack overflows on large inputs. I've reimplemented it in terms of `mapVectorWithIndex`.

Thanks!

- Ben