Closed Uditgulati closed 5 years ago
@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 :)
@prasunanand this PR is complete from my end. Please review it when free.
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_densefrom* functions.
Will also fix compiler warnings for remaining files.