Skip to content

Conversation

@TWiedemann
Copy link
Contributor

@TWiedemann TWiedemann commented May 2, 2025

Fixes #5986: String(a) for a rational function a with zero numerator throws an error. The problem was that ExtRepOfPolynomial_String normally returns a mutable string, but for a zero polynomial it used to return String(zero) which is immutable. Hence I changed this to ShallowCopy(String(zero)).

With this change, the example from #5986 works:

gap> x1 := Indeterminate(Rationals, 1);; x2 := Indeterminate(Rationals, 2);; x3 := Indeterminate(Rationals, 3);;
gap> a := (x1*x2)/(x1*x3) - x2/x3;
0/x_1
gap> String(a);
"0/x_1"

The issue that a is represented as 0/x_1 and not as 0 persists.

Text for release notes

none

@fingolfin
Copy link
Member

Thank you! That's a good change. Could you please apply the same change to hpcgap/lib/ratfun.gi, and also add a test case? E.g. in tst/testinstall/ratfun.tst or in a new file in tst/testbugfix/ >

@TWiedemann
Copy link
Contributor Author

Thank you! That's a good change. Could you please apply the same change to hpcgap/lib/ratfun.gi, and also add a test case? E.g. in tst/testinstall/ratfun.tst or in a new file in tst/testbugfix/ >

Done.

@fingolfin fingolfin added release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes backport-to-4.14 kind: bug Issues describing general bugs, and PRs fixing them kind: bug: unexpected error Issues describing bugs in which computation unexpectedly encounters an error, and PRs fixing them labels May 9, 2025
@fingolfin fingolfin enabled auto-merge (squash) May 9, 2025 15:08
@fingolfin fingolfin closed this Jun 18, 2025
auto-merge was automatically disabled June 18, 2025 16:05

Pull request was closed

@fingolfin fingolfin reopened this Jun 18, 2025
@fingolfin fingolfin enabled auto-merge (squash) June 18, 2025 16:05
@fingolfin fingolfin merged commit 3a54cf4 into gap-system:master Jun 19, 2025
69 of 80 checks passed
@TWiedemann TWiedemann deleted the tw/fix-string-rational-function branch June 19, 2025 19:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

kind: bug: unexpected error Issues describing bugs in which computation unexpectedly encounters an error, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them release notes: not needed PRs introducing changes that are wholly irrelevant to the release notes

Projects

None yet

Development

Successfully merging this pull request may close these issues.

String does not work for rational functions with zero numerator

2 participants