Improving the next code

52 views
Skip to first unread message

Juan Grados

unread,
Feb 25, 2018, 4:11:53 PM2/25/18
to sage-support, sage-a...@googlegroups.com
How can I improve the time for the next code?. Basically, I want to solve a large undetermined binary linear system and then I need to calculate its hamming weight.

A = random_matrix(GF(2), 10, 12, density=0.55)
b = random_vector(GF(2), 10)
particular_soln = A.solve_right(b, check=False)
A_right_kernel = A.right_kernel()
for homogeneous_soln in A_right_kernel:
    v = (particular_soln + homogeneous_soln)
    print len(v.nonzero_positions())


--
---------------------------------------------------------------------
MSc. Juan del Carmen Grados Vásquez
Laboratório Nacional de Computação Científica 
Tel: +55 21 97633 3228
(http://www.lncc.br/)
http://juaninf.blogspot.com
---------------------------------------------------------------------

David Joyner

unread,
Feb 25, 2018, 5:23:37 PM2/25/18
to sage-a...@googlegroups.com, SAGE support
On Sun, Feb 25, 2018 at 4:11 PM, Juan Grados <jua...@gmail.com> wrote:
> How can I improve the time for the next code?. Basically, I want to solve a
> large undetermined binary linear system and then I need to calculate its
> hamming weight.
>
> A = random_matrix(GF(2), 10, 12, density=0.55)
> b = random_vector(GF(2), 10)
> particular_soln = A.solve_right(b, check=False)
> A_right_kernel = A.right_kernel()
> for homogeneous_soln in A_right_kernel:
> v = (particular_soln + homogeneous_soln)
> print len(v.nonzero_positions())
>

You are computing the min wt of a coset of a binary linear code.
I don't know of a fast stand alone function that does this.

Printing slows you down a lot. Just make the list of wts using list
comprehension and find its minimum later.

For real speed, you make want to modify the C code in
GAP's AClosestVectorCombinationsMatFFEVecFFE.



>
> --
> ---------------------------------------------------------------------
> MSc. Juan del Carmen Grados Vásquez
> Laboratório Nacional de Computação Científica
> Tel: +55 21 97633 3228
> (http://www.lncc.br/)
> http://juaninf.blogspot.com
> ---------------------------------------------------------------------
>
> --
> You received this message because you are subscribed to the Google Groups
> "sage-algebra" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to sage-algebra...@googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Juan Grados

unread,
Feb 25, 2018, 8:04:27 PM2/25/18
to sage-a...@googlegroups.com, SAGE support
Thanks, David, 

I think that the problem is with the operation "+" I have using Profiler and when the matrix has dimensios, 12 x 19 these are the times

9.932s -- line 15: v = (particular_soln + homogeneous_soln)
0.004s -- line 17: print len(v.nonzero_positions())

Maybe there is some way to sum particular_soln + homogeneous_soln in a fast way?



> For more options, visit https://groups.google.com/d/optout.

--
You received this message because you are subscribed to the Google Groups "sage-algebra" group.
To unsubscribe from this group and stop receiving emails from it, send an email to sage-algebra+unsubscribe@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.
Reply all
Reply to author
Forward
0 new messages