On Wed, Apr 6, 2022 at 5:45 AM Jakub Komárek <jakom...@gmail.com> wrote:
>
> I have been experiencing some weird sage behavior regarding matroids (bug?).
>
> Sage session:
>
> >> sage: A = matrix([
> >> ....:     (24933.199686367003,-41014.0,-51015.0,0.0,0.0,0.0),
> >> ....:     (-0.8039596197196983,0.0,0.0,1.0,0.0,0.0),
> >> ....:     (0.0,-1.0,0.0,0.0,1.0,0.0),
> >> ....:     (0.0,0.0,-1.0,0.0,0.0,1.0)
> >> ....: ])
> >> sage: A_mat = Matroid(A)
> >> sage: fs = frozenset([0, 2])
> >> sage: A_mat.rank(fs)
> >> 2
> >> sage: list(A_mat.bases())
> >> [frozenset({0, 1, 2, 3}),
> >>  frozenset({0, 1, 3, 4}),
> >>  frozenset({1, 2, 3, 4}),
> >>  frozenset({0, 1, 4, 5}),
> >>  frozenset({1, 2, 4, 5}),
> >>  frozenset({1, 3, 4, 5}),
> >>  frozenset({0, 1, 3, 5}),
> >>  frozenset({1, 2, 3, 5})]
> >> sage: A_mat.rank(fs)
> >> 1
>
> At first sage gives the answer that the rank of the set of the first and 
> third column vector of the matrix is two (correctly, as they are linearly 
> independent), but after only listing (!) all matroid bases it changes the 
> answer to 1. The behavior I would expect is that it should still be 2.
>

Scaling A to have integer entries gives:

sage: A = 
matrix([(249331996863670030000,-41014000000000000000,-510150000000000000000,0,0,0),(-39596197196983,0,0,10000000000000000,0,0),(0.0
....: 
,-10000000000000000,0,0,10000000000000000,0),(0,0,-10000000000000000,0,0,10000000000000000)])
sage: A_mat = Matroid(A)
sage: fs = frozenset([0, 2])
sage: A_mat.rank(fs)
2
sage: list(A_mat.bases())
[frozenset({0, 1, 2, 3}),
 frozenset({0, 1, 3, 4}),
 frozenset({1, 2, 3, 4}),
 frozenset({0, 2, 3, 4}),
 frozenset({0, 1, 2, 4}),
 frozenset({0, 1, 4, 5}),
 frozenset({0, 2, 4, 5}),
 frozenset({2, 3, 4, 5}),
 frozenset({1, 3, 4, 5}),
 frozenset({0, 3, 4, 5}),
 frozenset({0, 1, 3, 5}),
 frozenset({1, 2, 3, 5}),
 frozenset({0, 1, 2, 5})]
sage: A_mat.rank(fs)
2
sage: version()
'SageMath version 9.3.rc0, Release Date: 2021-03-23'


> I did not manage to simplify the matrix, all the simplifications that I tried 
> resulted in sage behaving sensibly. If this is a numerical issue that cannot 
> be fixed, is there a way to work around this behavior? Or are sage matroids 
> just not well-suited for matrices of floating-point numbers?
>
> As a consequence of this behavior, the matroid function `circuits()` does not 
> work properly for this matroid, as its implementation uses the `rank()` and 
> `bases()` functions similarly as shown above.
>
> Sage version: SageMath version 9.5, Release Date: 2022-01-30
> OS: Arch linux
>
> I will be thankful for any advice, great job with sage otherwise!
>
> --
> You received this message because you are subscribed to the Google Groups 
> "sage-devel" group.
> To unsubscribe from this group and stop receiving emails from it, send an 
> email to sage-devel+unsubscr...@googlegroups.com.
> To view this discussion on the web visit 
> https://groups.google.com/d/msgid/sage-devel/bb41c35f-ba26-4a23-bdde-314d0d10c4c1n%40googlegroups.com.

-- 
You received this message because you are subscribed to the Google Groups 
"sage-devel" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to sage-devel+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/sage-devel/CAEQuuAUrjfFGiQFy%3DbBUg8uOn%2Bg1obu-zeNhp-9fDjDp84-70g%40mail.gmail.com.

Reply via email to