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

Is it possible to use something like 1-x:1:10-x #239

Open
zhaoli-IHEP opened this issue Oct 18, 2021 · 1 comment
Open

Is it possible to use something like 1-x:1:10-x #239

zhaoli-IHEP opened this issue Oct 18, 2021 · 1 comment

Comments

@zhaoli-IHEP
Copy link

zhaoli-IHEP commented Oct 18, 2021

We were trying to calculate like (1-x)*(2-x)*(3-x)*...*(10-x). And now we use (1:10).-x, which in fact gives in REPL 1 - x:1:10 - x. However, it seems we cannot directly use 1 - x:1:10 - x or 1 - x:one(Basic):10 - x. Could it have some way to do this?

@isuruf
Copy link
Member

isuruf commented Oct 18, 2021

diff --git a/src/mathops.jl b/src/mathops.jl
index 335cf2c..ec765d1 100644
--- a/src/mathops.jl
+++ b/src/mathops.jl
@@ -97,7 +97,7 @@ Base.convert(::Type{Basic}, x::Irrational{:φ}) = (1 + Basic(5)^Basic(1//2))/2
 Base.convert(::Type{BasicType}, x::Irrational) = BasicType(convert(Basic, x))
 
 ## Logical operators
-Base.:<(x::SymbolicType, y::SymbolicType) = N(x) < N(y)
+Base.:<(x::SymbolicType, y::SymbolicType) = N(expand(x - y)) < 0
 Base.:<(x::SymbolicType, y) = <(promote(x,y)...)
 Base.:<(x, y::SymbolicType) = <(promote(x,y)...)
 

will get you a little bit closer, but not enough. It will then fail with calculating remainder.

Maybe overriding steprange_last is the best approach here?

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

No branches or pull requests

2 participants