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

Optimize linear codes: __eq__, dual_code and commented debug lines #19492

Closed
sagetrac-dlucas mannequin opened this issue Oct 28, 2015 · 15 comments
Closed

Optimize linear codes: __eq__, dual_code and commented debug lines #19492

sagetrac-dlucas mannequin opened this issue Oct 28, 2015 · 15 comments

Comments

@sagetrac-dlucas
Copy link
Mannequin

sagetrac-dlucas mannequin commented Oct 28, 2015

Some code in LinearCode.py is quite old and/or slow, and could be optimized.
This tickets proposes a faster implementation for __eq__ and dual_code methods.
It also removes a lot of commented debug lines.

Component: coding theory

Author: David Lucas

Branch/Commit: b869837

Reviewer: Vincent Delecroix

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

@sagetrac-dlucas sagetrac-dlucas mannequin added this to the sage-6.10 milestone Oct 28, 2015
@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Oct 28, 2015

Branch: u/dlucas/clean_linear_code

@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Oct 28, 2015

Commit: d64c360

@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Oct 28, 2015

comment:2

Let C be a linear code with H a parity check matrix of C. The generator matrix of C's dual is H. I made changes in AbstractLinearCode's dual_code method to use that property instead of the old implementation and got something faster.

I also rewrote AbstractLinearCode's __eq__ which is now less heavy and a bit faster.

Finally, I removed a lot of old debug prints that were still present in this file as commented lines.

This is now ready for review.


New commits:

eba939bChanges in dual_code method
d64c360Changes in `__eq__` method, removed commented debug lines

@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Oct 28, 2015

Author: David Lucas

@jdemeyer jdemeyer changed the title Cleaning linear codes: __eq__, dual_code and commented debug lines Optimize linear codes: __eq__, dual_code and commented debug lines Nov 29, 2015
@videlec
Copy link
Contributor

videlec commented Jan 2, 2016

comment:4

The following would be cleaner on two lines.

+        Ks, rbas = self.parity_check_matrix().right_kernel(), right.gens()

Otherwise it looks good.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 5, 2016

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

f3a7f07Integrated reviewer's comment

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 5, 2016

Changed commit from d64c360 to f3a7f07

@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Jan 5, 2016

comment:6

Thanks for your input.

I changed the code to what you suggested. I also fixed a silly copy-paste mistake two lines below the one you mentioned.

David

@videlec
Copy link
Contributor

videlec commented Jan 5, 2016

comment:7

While you are at it, the print statements like

print " t = ",t," , v = ",n," , k = ",w," , lambda = ",wts[w]*binomial(w,t)/binomial(n,t)

are really ugly. Could you do something cleaner like

print "t={} v={} k={} lambda={}".format(t, n, w, wts[w]*binomial(w,t)/binomial(n,t))

@jdemeyer
Copy link

jdemeyer commented Jan 6, 2016

comment:8

Even better would be

print("t={} v={} k={} lambda={}".format(t, n, w, wts[w]*binomial(w,t)/binomial(n,t)))

since that's compatible with Python 2 and 3.

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 6, 2016

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

b869837Changed some print statements to something cleaner

@sagetrac-git
Copy link
Mannequin

sagetrac-git mannequin commented Jan 6, 2016

Changed commit from f3a7f07 to b869837

@sagetrac-dlucas
Copy link
Mannequin Author

sagetrac-dlucas mannequin commented Jan 6, 2016

comment:10

It's done.
I picked Jeroen's suggestion for the new statements.

@videlec
Copy link
Contributor

videlec commented Jan 6, 2016

Reviewer: Vincent Delecroix

@vbraun
Copy link
Member

vbraun commented Jan 7, 2016

Changed branch from u/dlucas/clean_linear_code to b869837

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

3 participants