cjfuller/nmatrix — pull request #1 by mohawkjohn (2013-09-25 21:44:18+00:00)
Title: Revision of unary math operators

Thanks for the commit earlier. I spent a while on this one because there's a good way to do it which will automatically loop in the other stypes. And yes, it does make sense to allow unary operations on these!

If you have a Yale matrix [[0,1],[0,2]], it's (probably) going to be stored with a default value of 0. If you call cosine on it, the resulting matrix will have a default value of 1 instead. NMatrix is smart like this. It also works that way for list.

It still needs a bit of work, but I hope I provided you with enough examples to implement the error function and other things you were working on. You can see from this commit exactly where the changes were made in the C/C++ code.

It also still needs to have casting defined in math.rb. It'll work without it, but I don't want people to be surprised when they call `x.sin` on a `:float64` matrix and get an `:object` matrix back. If you could go through and figure that stuff out, I'd be grateful.

There were also some minor problems with the spec. Namely, you were forcing a cast from `x.fn()` to an integer matrix even when the result of `fn()` was non-integral.

Thanks for lighting a fire under me for this. These functions have been needed for a while. =)