-
Notifications
You must be signed in to change notification settings - Fork 2
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
More semi-ring algebras #9
Conversation
Another problem is that now all these different Tropical type are shown as |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is a very solid PR, I just have a few minor suggestions. I wish we could show the definitions of these algebras in the README, e.g. a table with (+, *, 1, 0, subscript) as columns and different algebra types as rows.
src/TropicalNumbers.jl
Outdated
Base.div(a::$T, b::Bool) = b ? a : a / zero(a) | ||
Base.div(b::Bool, a::$T) = b ? inv(a) : zero(a) | ||
# Base.div(a::$T, b::Bool) = b ? a : a / zero(a) | ||
# Base.div(b::Bool, a::$T) = b ? inv(a) : zero(a) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good catch! Please remove the lines commented out.
src/tropical_minplus.jl
Outdated
end | ||
end | ||
|
||
Base.show(io::IO, t::TropicalMinPlus) = Base.print(io, "$(t.n)ₜ") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I wish they could be printed with a different subscript.
src/TropicalNumbers.jl
Outdated
end | ||
end | ||
|
||
const TropicalMaxPlus = Tropical |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Good job! This is exactly what I meant.
Another comment: we'd better add a new abstract type |
About the subscripts, you may find a complete list of unicode here: Among which I would suggest
I do not have strong opinion on how they look like. It is more important to explain these convensions in the documentation. |
The following changes have been made:
The latest test result is shown below (please see the indices):
|
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great work, I think all the changes make sense to me. I forgot to mention not using error handling in the consctructor.
We should remove all error handling in the default constructor of TropicalMaxMul
, otherwise the code can not run on GPU.
A better practise would be using unsafe_xxx
as the constructor without error handling. However, here to make life easier, we can also assume users know the negative numbers are forbidden in this algebra.
Either approach is good to me.
All the error handling are removed, here we may just assume all users know how to use it properly. |
Codecov Report
@@ Coverage Diff @@
## master #9 +/- ##
==========================================
- Coverage 86.41% 85.06% -1.36%
==========================================
Files 3 6 +3
Lines 81 154 +73
==========================================
+ Hits 70 131 +61
- Misses 11 23 +12
|
Good job. I just registered a new version v0.6.0. 🎉 |
Wow, thanks a lot. |
I add more semi-ring algebras to the package, including the
TropicalMaxMul
,TropicalMinPlus
andTropicalAndor
, and I also give the original typeTropical
an extra nameTropicalMaxPlus
, all tests passed for these algebras.TropicalMinMul
is not added, sinceI changed the rule about
Bool
type fromto
The original one does not work well with
TropicalMaxMul
, sinceThis change doesn't affect the original tests.