Fix compiler warnings by Uditgulati · Pull Request #21 · SciRuby/numruby (original) (raw)
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service andprivacy statement. We’ll occasionally send you account related emails.
Already on GitHub?Sign in to your account
Conversation3 Commits3 Checks0 Files changed
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.Learn more about bidirectional Unicode characters
[ Show hidden characters]({{ revealButtonHref }})
Fixed compiler warnings for sparse.c. Also, fixed a switch statement typo.
To prevent the nesting of switch(input->sptype) and switch(input->dtype), I passed the input->dtype to get_dense_from_* functions.
Will also fix compiler warnings for remaining files.
@prasunanand I've raised SyntaxError if greater or lesser comparison is done on complex numbers as Ruby also does not support this for Complex type. But, numpy supports it (Python complex doesn't) by doing a comparison on real part and then on imaginary. Should I keep it this way or change it to work like numpy? Or I could make comparison based on the magnitude of complex numbers.
Ruby Complex example
[1] pry(main)> a = 2+3i
=> (2+3i)
[2] pry(main)> b = 23i
=> (0+23i)
[3] pry(main)> b = 2+3i
=> (2+3i)
[4] pry(main)> a == b
=> true
[5] pry(main)> b = 2+4i
=> (2+4i)
[6] pry(main)> a < b
NoMethodError: undefined method <' for (2+3i):Complex from (pry):6:in
pry'
numpy complex128 example
import numpy as np a = np.array([2+3j, 2+4j]) a[0] (2+3j) a[1] (2+4j) a[0] == a[1] False a[0] < a[1] True a[0] = 4+2j a[0] < a[1] False a[1] = 2+100j a[0] < a[1] False
When in doubt, go the numpy way :)
Uditgulati changed the title
WIP: Fix compiler warnings Fix compiler warnings
@prasunanand this PR is complete from my end. Please review it when free.
2 participants