SciRuby / nmatrix

Dense and sparse linear algebra library for Ruby via SciRuby
Other
469 stars 133 forks source link

fixes det method for dtype object #575

Closed npriyadarshi closed 7 years ago

npriyadarshi commented 7 years ago

@mohawkjohn In continuation with the work done by you in PR #501.

translunar commented 7 years ago

Seems like you're missing some code here.

npriyadarshi commented 7 years ago

@mohawkjohn i do not understand what part of my code is missing could you please help me out with this. Is this not the correct way to implement it?

translunar commented 7 years ago

Let's try this: can you please explain to me how your implementation works?

npriyadarshi commented 7 years ago

In the det function i type cast the object dtype to float.

translunar commented 7 years ago

What happens if the Object can't be cast to a decimal value? (For that matter, why would we have an :object dtype at all if we could always just treat it as a decimal?)

npriyadarshi commented 7 years ago

@mohawkjohn in lib/nmatrix/math.rb in the method det .getrf is being used on a copy(with typecasted dtype) of the matrix whose determinant is to be found out. should i throw an exception if it cannot be cast into decimal value? or is there any other way to fix the issue?

npriyadarshi commented 7 years ago

should i change the det function so that it does not require LAPACK function and the i can follow as in PR #514 ?

translunar commented 7 years ago

@npriyadarshi Let's rewind a bit. Why do we have an :object dtype? How does it differ from the float and integer dtypes?

npriyadarshi commented 7 years ago

Object dtypes represent ruby objects i mean any variable in ruby be it string,decimal, integer etc. I dont actually understand why we have dtype object.

translunar commented 7 years ago

We have object dtypes because matrix operations like determinants exist not only for the set of nxn integer matrices and the set of nxn real matrices, but others as well. We cannot possibly create a dtype for each of these cases because we can't envision them all. So the Ruby object dtype allows people to use those algorithms on any arbitrary domain.

translunar commented 7 years ago

I'm going to close this for now. You're welcome to discuss on the Google Group, or reopen when you think you've got a solution ready.