-
-
Notifications
You must be signed in to change notification settings - Fork 35
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
LIPS compares complex numbers for order #248
Comments
(Does it implement a partial order? Then, does it use the norm or is it a lexicographic order? It would then be nice to document this -- or perhaps not allow the comparison) |
Yes, I think that it should throw an error for comparing complex numbers. I was asking (on StackOverflow or Math Exchange) about comparing complex numbers and long ago someone replied that it doesn't make sense to compare them. I think that the reason why comparison works is because all operators use polymorphism so every number type gets those for free even if the result doesn't make sense. |
Added type checking to the compare operations. Also, the comparison was implemented for complex numbers so I've deleted it and thrown an error instead. It looked like this: LComplex.prototype.cmp = function(n) {
const [a, b] = this.coerce(n);
const [re_a, re_b] = a.__re__.coerce(b.__re__);
const re_cmp = re_a.cmp(re_b);
if (re_cmp !== 0) {
return re_cmp;
} else {
const [im_a, im_b] = a.__im__.coerce(b.__im__);
return im_a.cmp(im_b);
}
}; It was a naive complex comparison that I'd implemented before I knew that it didn't make sense to compare complex numbers. |
Hello,
It seems that LIPS accepts
<
,>
,<=
,>=
for complex numbers:The text was updated successfully, but these errors were encountered: