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

Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to errors resp. wrong results if multiplication with coefficients from the right is not defined resp. not commutative #4482

Merged
merged 1 commit into from
May 12, 2021

Conversation

cdwensley
Copy link
Contributor

@cdwensley cdwensley commented May 10, 2021

Description

This one-line change to lib/vspchom.gi attempts to fix issue #4481.
The fix is just to change the order of vectors in LinearCombination( x, maxi[2] );

Text for release notes

Fixed the construction of linear mappings by images in certain situations where it is essential that multiplying elements in the image with coefficients happens from the left, not from the right. (Note that multiplication from the left is assumed, but in many computations it does not make a difference.)
Before the fix, one got an error if multiplying with coefficients from the right is not defined, and one got a perhaps wrong result if this multiplication is defined but not commutative.
Examples of the error case can be constructed with algebras generated by algebra homomorphisms as images of the linear mapping.

(End of text for release notes)

Checklist for pull request reviewers

  • proper formatting

If your code contains kernel C code, run clang-format on it; the
simplest way is to use git clang-format, e.g. like this (don't
forget to commit the resulting changes):

git clang-format $(git merge-base HEAD master)
  • usage of relevant labels

    1. either release notes: not needed or release notes: to be added
    2. at least one of the labels bug or enhancement or new feature
    3. for changes meant to be backported to stable-4.X add the backport-to-4.X label
    4. consider adding any of the labels build system, documentation, kernel, library, tests
  • runnable tests

  • lines changed in commits are sufficiently covered by the tests

  • adequate pull request title

  • well formulated text for release notes

  • relevant documentation updates

  • sensible comments in the code

@cdwensley cdwensley added kind: bug Issues describing general bugs, and PRs fixing them release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels May 10, 2021
@cdwensley
Copy link
Contributor Author

This fix for issue #383, or some alternative, is required by the XModAlg package

@fingolfin
Copy link
Member

Issue #383 is about "Fix version header dependency"... ?!

@cdwensley
Copy link
Contributor Author

Apologies, it is issue #4481 (number 383 of the open issues).

@wilfwilson wilfwilson changed the title fix bug in MakeImagesInfoLinearGeneralMappingByImages Fix bug in MakeImagesInfoLinearGeneralMappingByImages May 11, 2021
@wilfwilson
Copy link
Member

Thanks for spotting this.

If you can see a way of reasonably doing this, could you please add a test (to either tst/testinstall/vspchom.tst, or to a new file in tst/testbugfix/ following the style there) that demonstrates the now-correct behaviour?

Ideally it would be a test that would fail/give an error/give the wrong answer in the current master branch, but which of course gives the right answer with this PR.

Copy link
Member

@wilfwilson wilfwilson left a comment

Choose a reason for hiding this comment

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

Thank you, nice.

@cdwensley
Copy link
Contributor Author

The test 2021-05-11-LeftModHom.tst has been added to tst/testbugfix, and all checks are still passing.
The actual fix was first tried out on a "let's see if this works" basis, without any understanding why, so it would be best if someone with a good knowledge of algebras in GAP had a look, e.g. @ThomasBreuer.

@ThomasBreuer
Copy link
Contributor

Thanks, @cdwensley, for the fix.

Yes, the ordering of arguments in the code line in question was wrong.
I have looked through the instances of LinearCombination( in the GAP library, all except the one which you found look correct.

I think that the bug can also lead to wrong results (not only to error messages) if one considers suitable row vector spaces over noncommutative rings.

@fingolfin
Copy link
Member

I think we need a different text for the release notes; MakeImagesInfoLinearGeneralMappingByImages is an undocumented internal function, telling users that it has been fixed is IMHO problematic, as it might cause people to think that it is documented now, while at the same time not really telling them how to determine whether it might have affected them.

So instead we should list documented functions that were directly (or indirectly?) affected by this

@fingolfin fingolfin merged commit 681b9fb into gap-system:master May 12, 2021
@cdwensley
Copy link
Contributor Author

How about "Fix for AlgebraGeneralMappingByImages when one of the algebras is generated by algebra homomorphisms."? (I've no idea how to change the "Text for release notes".)

@cdwensley cdwensley deleted the leftmodhom branch May 12, 2021 08:55
@ThomasBreuer
Copy link
Contributor

I have edited the text for the release notes, please check if it is sufficient now.

@cdwensley
Copy link
Contributor Author

That looks very thorough.

@fingolfin fingolfin added kind: bug: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug: unexpected error Issues describing bugs in which computation unexpectedly encounters an error, and PRs fixing them labels Aug 17, 2022
@fingolfin fingolfin changed the title Fix bug in MakeImagesInfoLinearGeneralMappingByImages Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to error if multiplying with coefficients from the right is not defined, and possibly wrongs result if this multiplication is defined but not commutative Aug 17, 2022
@fingolfin fingolfin changed the title Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to error if multiplying with coefficients from the right is not defined, and possibly wrongs result if this multiplication is defined but not commutative Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to an error if multiplying with coefficients from the right is not defined, and possibly wrong results if this multiplication is defined but not commutative Aug 17, 2022
@fingolfin fingolfin changed the title Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to an error if multiplying with coefficients from the right is not defined, and possibly wrong results if this multiplication is defined but not commutative Fix bug in MakeImagesInfoLinearGeneralMappingByImages that could lead to errors resp. wrong results if multiplication with coefficients from the right is not defined resp. not commutative Aug 17, 2022
@fingolfin fingolfin added release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes and removed release notes: to be added PRs introducing changes that should be (but have not yet been) mentioned in the release notes labels Aug 17, 2022
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: wrong result Issues describing bugs that result in mathematically or otherwise wrong results, and PRs fixing them kind: bug Issues describing general bugs, and PRs fixing them release notes: use title For PRs: the title of this PR is suitable for direct use in the release notes topic: library
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants