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

tropical determinant via Hungarian method #3943

Merged
merged 10 commits into from
Jul 18, 2024
Merged

tropical determinant via Hungarian method #3943

merged 10 commits into from
Jul 18, 2024

Conversation

micjoswig
Copy link
Member

@micjoswig micjoswig commented Jul 16, 2024

The previous implementation (via Leibniz' rule) was not useful. It is now replaced via polymake's implementation of the Hungarian method.

To see the difference, here are two computations with v.1.1.1:


julia> @time det(matrix(tropical_semiring(), rand(0:9, 100, 100)))
ERROR: OverflowError: 100 is too large to look up in the table; consider using `factorial(big(100))` instead
Stacktrace:
 [1] factorial_lookup
   @ ./combinatorics.jl:19 [inlined]
 [2] factorial
   @ ./combinatorics.jl:27 [inlined]
 [3] AbstractAlgebra.Generic.AllPerms(n::Int64)
   @ AbstractAlgebra.Generic ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/GenericTypes.jl:57
 [4] iterate
   @ ~/.julia/packages/AbstractAlgebra/EYoda/src/generic/PermGroups.jl:634 [inlined]
 [5] det(A::AbstractAlgebra.Generic.MatSpaceElem{TropicalSemiringElem{typeof(min)}})
   @ Oscar ~/.julia/packages/Oscar/38HwK/src/TropicalGeometry/matrix.jl:35
 [6] macro expansion
   @ ./timing.jl:279 [inlined]
 [7] top-level scope
   @ ./REPL[10]:1

julia> @time Polymake.tropical.tdet(matrix(tropical_semiring(), rand(0:9, 100, 100)))
  0.016758 seconds (328.42 k allocations: 3.419 MiB, 22.80% compilation time)
pm::TropicalNumber<pm::Min, pm::Rational>
0

Copy link
Member

@YueRen YueRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

A very welcome change!

src/TropicalGeometry/matrix.jl Outdated Show resolved Hide resolved
@micjoswig
Copy link
Member Author

@danteluber please have a look

@micjoswig micjoswig requested a review from YueRen July 16, 2024 14:07
YueRen
YueRen previously requested changes Jul 16, 2024
src/TropicalGeometry/matrix.jl Outdated Show resolved Hide resolved
@YueRen YueRen dismissed their stale review July 17, 2024 18:48

code overhauled, will start new review once tests are through

Copy link

codecov bot commented Jul 18, 2024

Codecov Report

All modified and coverable lines are covered by tests ✅

Project coverage is 84.01%. Comparing base (71c1f3e) to head (7d0e8c7).
Report is 10 commits behind head on master.

Additional details and impacted files
@@            Coverage Diff             @@
##           master    #3943      +/-   ##
==========================================
+ Coverage   84.00%   84.01%   +0.01%     
==========================================
  Files         592      592              
  Lines       81624    81672      +48     
==========================================
+ Hits        68566    68616      +50     
+ Misses      13058    13056       -2     
Files Coverage Δ
src/TropicalGeometry/matrix.jl 100.00% <100.00%> (ø)

... and 18 files with indirect coverage changes

@micjoswig micjoswig requested a review from YueRen July 18, 2024 10:09
Copy link
Member

@YueRen YueRen left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Everything looks great. Thanks for this very useful feature!

@benlorenz benlorenz merged commit 2bca928 into master Jul 18, 2024
29 of 30 checks passed
@benlorenz benlorenz deleted the mj/feature/tdet branch July 18, 2024 13:37
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

5 participants