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

make free_module_generic_pid also work for pid's other than integers #11751

Closed
koffie opened this issue Aug 26, 2011 · 25 comments
Closed

make free_module_generic_pid also work for pid's other than integers #11751

koffie opened this issue Aug 26, 2011 · 25 comments

Comments

@koffie
Copy link

koffie commented Aug 26, 2011

Before this patch the following code would fail

sage: R.<x> = QQ[]
sage: L = R^1
sage: M = L.span([[1/x]])
sage: M([1/x])

Apply

  1. attachment: 11751_free_module_generic_pid-fix.patch
  2. attachment: trac_11751_free_module_generic_pid-review.patch
  3. attachment: trac_11751_whitespace.patch
    to the Sage library.

Component: linear algebra

Author: Maarten Derickx, Julian Rueth

Reviewer: Julian Rueth, Maarten Derickx

Merged: sage-4.7.2.alpha3

Issue created by migration from https://trac.sagemath.org/ticket/11751

@koffie
Copy link
Author

koffie commented Sep 1, 2011

comment:1

Attachment: 11751_free_module_generic_pid-fix.patch.gz

@koffie

This comment has been minimized.

@koffie

This comment has been minimized.

@koffie
Copy link
Author

koffie commented Sep 1, 2011

comment:3

Changing the is into == is needed to make the example in the description work but in introduced some other strange bugs:

sage -t  devel/sage-main/sage/modules/quotient_module.py # 1 doctests failed
sage -t  devel/sage-main/sage/modules/fg_pid/fgp_element.py # 3 doctests failed
sage -t  devel/sage-main/sage/modules/free_module_element.pyx # 3 doctests failed

@koffie
Copy link
Author

koffie commented Sep 1, 2011

comment:4

A full output of the errors is shown in http://pastebin.com/4B4xmRDZ

@saraedum
Copy link
Member

saraedum commented Sep 2, 2011

comment:5

It seems that the line entries = [R(x) for x in entries] in coerce.pyx (roughly line 3540) is wrong. The components of a element in a free R module may not be in R at all. I'm working on a fix for that.

@koffie
Copy link
Author

koffie commented Sep 5, 2011

comment:7

The patch looks good :). Didn't try it yet how it works with doctests and yet but at least the code looks reasonable.

If this passes all test, then at least I want something like the following as a doctest:

sage: L=K^2
sage: R=L.span([[x,1/x]])
sage: R.basis()[0][0]
x
sage: R.basis()[0][0].parent()
Fraction Field of Univariate Polynomial Ring in x over Rational Field
sage: R=L.span([[x,x^2]])
sage: R.basis()[0][0].parent()
Univariate Polynomial Ring in x over Rational Field

Since if we are going to look at the parent of one specific element, then we certainly want that it depends in the right way of the other elements.

A neater way to do this would be to actually store "coefficient_ring" in the parent, since I think that

parent.basis()[0][0].parent()

Is way to many steps removed from parent to actually directly acces from the code. But this is just nitpicking.

I'm now doctesting your patch.

@koffie
Copy link
Author

koffie commented Sep 10, 2011

Attachment: trac_11751_free_module_generic_pid-review.patch.gz

fixes the failing doctests

@koffie
Copy link
Author

koffie commented Sep 10, 2011

comment:8

I added a new patch, since we should also fix sparse modules (they suffer from the exact same bug). Running doctests now.

@koffie
Copy link
Author

koffie commented Sep 10, 2011

comment:9

All tests pass so this again needs a review for the added sparse code.

@koffie

This comment has been minimized.

@saraedum
Copy link
Member

Author: Maarten Derickx, Julian Rueth

@saraedum

This comment has been minimized.

@saraedum
Copy link
Member

Reviewer: Maarten Derickx, Julian Rueth

@saraedum saraedum changed the title make free_module_generic_pid also work for pid's other then integers make free_module_generic_pid also work for pid's other than integers Sep 19, 2011
@saraedum
Copy link
Member

comment:12

the patches apply to 4.7.2.alpha2 and all doctests pass.

@koffie
Copy link
Author

koffie commented Sep 19, 2011

comment:13

apply: 11751_free_module_generic_pid-fix.patch, trac_11751_free_module_generic_pid-review.patch and trac_11751_whitespace.patch

@koffie

This comment has been minimized.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Sep 19, 2011

Changed reviewer from Maarten Derickx, Julian Rueth to Julian Rueth, Maarten Derickx

@nexttime

This comment has been minimized.

@nexttime
Copy link
Mannequin

nexttime mannequin commented Sep 27, 2011

Merged: sage-4.7.2.alpha3

@nexttime nexttime mannequin removed the s: positive review label Sep 27, 2011
@nexttime nexttime mannequin closed this as completed Sep 27, 2011
@jdemeyer
Copy link

jdemeyer commented Oct 4, 2011

small review patch to fix some whitespace and doc issues

@jdemeyer
Copy link

comment:16

Attachment: trac_11751_whitespace.patch.gz

I really don't like the way how this was fixed. First of all, why is this even a bug? If you need fractions, I think you should use the fraction field from the beginning.

Second, it causes the computation of a basis(!) every time that vector() is called.

I am working on initialization of vectors in #17561 and I would actually like to revert this fix and make

sage: R.<x> = QQ[] 
sage: L = R^1 
sage: L.span([(1/x,)]) 

a TypeError again.

@jdemeyer
Copy link

comment:17

ok, I get it now. The issue is more complex than what the description shows.

@jdemeyer

This comment has been minimized.

@jdemeyer
Copy link

comment:18

Anyway, I'm fixing the basis() issue by adding a new method basis_ring() to free modules.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

5 participants