Improved performance slightly

Well github ate my last pull request; let's see how this one goes.

This seems like a neat idea, but the performance isn't great.  I moved the inv.logit.mat() function to C as that seemed like the lowest hanging fruit, but more could be done.