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

overflow for vector mod2 dense #21746

Closed
videlec opened this issue Oct 23, 2016 · 22 comments
Closed

overflow for vector mod2 dense #21746

videlec opened this issue Oct 23, 2016 · 22 comments

Comments

@videlec
Copy link
Contributor

videlec commented Oct 23, 2016

sage: VS = VectorSpace(GF(2),1)
sage: VS([2**64])
Traceback (most recent call last):
...
OverflowError: Python int too large to convert to C long

Component: linear algebra

Author: Vincent Delecroix

Branch/Commit: 428c88e

Reviewer: Jeroen Demeyer, Travis Scrimshaw

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

@videlec videlec added this to the sage-7.5 milestone Oct 23, 2016
@videlec
Copy link
Contributor Author

videlec commented Oct 23, 2016

Author: Vincent Delecroix

@videlec
Copy link
Contributor Author

videlec commented Oct 23, 2016

Branch: u/vdelecroix/21746

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 23, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

9a5227221746: fix overflow for dense vector mod 2

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 23, 2016

Commit: 9a52272

@jdemeyer
Copy link

Reviewer: Jeroen Demeyer

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 25, 2016

Branch pushed to git repo; I updated commit sha1 and set ticket back to needs_review. New commits:

d1c54b121746: fix doctest in coding/

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 25, 2016

Changed commit from 9a52272 to d1c54b1

@videlec
Copy link
Contributor Author

videlec commented Oct 25, 2016

comment:5

Fixed doctest failure in coding/. Needs review again.

@tscrim
Copy link
Collaborator

tscrim commented Oct 25, 2016

comment:6

This branch does result in ~10% slowdown:

sage: V = VectorSpace(GF(2), 2^10)
sage: %timeit V([1]*(2^10))
The slowest run took 5.95 times longer than the fastest. This could mean that an intermediate result is being cached.
10000 loops, best of 3: 49.8 µs per loop

Before:

sage: V = VectorSpace(GF(2), 2^10)
sage: %timeit V([1]*(2^10))
The slowest run took 5.69 times longer than the fastest. This could mean that an intermediate result is being cached.
10000 loops, best of 3: 45.8 µs per loop

However, changing the for loop over enumerate back to for i from 0 <= i < self._degree: and setting xi = x[i] doesn't have a noticeable impact. So I think we have to deal with this.

I do have one nitpick: change the ZeroDivisionError to start with a lowercase. Once that is done, you can put this back to a positive review.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2016

Changed commit from d1c54b1 to 428c2cd

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

428c2cd21746: remove enumerate + cleaning

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2016

Branch pushed to git repo; I updated commit sha1. This was a forced push. New commits:

65894e521746: remove enumerate + cleaning

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 26, 2016

Changed commit from 428c2cd to 65894e5

@videlec
Copy link
Contributor Author

videlec commented Oct 26, 2016

comment:9

Thanks for the timings!

I removed the enumerate and also did some cleaning in the case x = 0. This code is completely useless

for i from 0 <= i < self._degree:
    mzd_set_ui(self._entries, 0)

@jdemeyer
Copy link

comment:10

The enumerate is optimized by Cython, so no need to remove it!

@tscrim
Copy link
Collaborator

tscrim commented Oct 26, 2016

comment:11

I realize the phrasing in my comment was somewhat vague too; I meant we have to just live with the slowdown. I did come to the conclusion that enumerate was likely optimized by Cython, but it is good to know. Anyways, removing it is a net-zero change, so I'm setting this back to a positive review.

@tscrim
Copy link
Collaborator

tscrim commented Oct 26, 2016

Changed reviewer from Jeroen Demeyer to Jeroen Demeyer, Travis Scrimshaw

@vbraun
Copy link
Member

vbraun commented Oct 30, 2016

comment:12

segfault galore... see patchbot

@videlec
Copy link
Contributor Author

videlec commented Oct 30, 2016

comment:13

Indeed. I am able to reproduce it with the shorter

sage: (GF(2)**0).zero_vector()

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 30, 2016

Branch pushed to git repo; I updated commit sha1. New commits:

428c88e21746: fix segementation fault for 0-dim spaces

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Oct 30, 2016

Changed commit from 65894e5 to 428c88e

@vbraun
Copy link
Member

vbraun commented Nov 2, 2016

Changed branch from u/vdelecroix/21746 to 428c88e

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

4 participants