Skip to content
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 and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix compiler warnings #21

Merged
merged 3 commits into from Jul 29, 2019
Merged

Fix compiler warnings #21

merged 3 commits into from Jul 29, 2019

Conversation

Uditgulati
Copy link
Member

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.

@Uditgulati
Copy link
Member Author

@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

@prasunanand
Copy link
Member

When in doubt, go the numpy way :)

@Uditgulati Uditgulati changed the title WIP: Fix compiler warnings Fix compiler warnings Jul 16, 2019
@Uditgulati
Copy link
Member Author

@prasunanand this PR is complete from my end. Please review it when free.

@prasunanand prasunanand merged commit ebb61b5 into SciRuby:master Jul 29, 2019
@Uditgulati Uditgulati deleted the warnings branch August 4, 2019 10:53
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

2 participants