ASKSAGE: Sage Q&A Forum - RSS feedhttps://ask.sagemath.org/questions/Q&A Forum for SageenCopyright Sage, 2010. Some rights reserved under creative commons license.Sat, 28 Nov 2015 19:36:54 +0100Enumerate all solutions to linear system over finite fieldhttps://ask.sagemath.org/question/31163/enumerate-all-solutions-to-linear-system-over-finite-field/ Assume I have a matrix $A$ and a vector $b$, both over some finite field $\mathrm{GF}(q)$. I would like to enumerate _all_ solutions to $A x = b$ (there are only finitely many).
I can generate a particular solution using `A \ b` and I can generate the nullspace of $A$ using `A.right_kernel()`, but how should I combine the two to enumerate all solutions?Sat, 28 Nov 2015 19:16:35 +0100https://ask.sagemath.org/question/31163/enumerate-all-solutions-to-linear-system-over-finite-field/Answer by d125q for <p>Assume I have a matrix $A$ and a vector $b$, both over some finite field $\mathrm{GF}(q)$. I would like to enumerate _all_ solutions to $A x = b$ (there are only finitely many).</p>
<p>I can generate a particular solution using <code>A \ b</code> and I can generate the nullspace of $A$ using <code>A.right_kernel()</code>, but how should I combine the two to enumerate all solutions?</p>
https://ask.sagemath.org/question/31163/enumerate-all-solutions-to-linear-system-over-finite-field/?answer=31164#post-id-31164 Okay, I found the solution. Finite vector spaces support iteration, so one can simply do:
particular_soln = A.solve_right(b)
for homogeneous_soln in A.right_kernel():
particular_soln + homogeneous_soln
Sat, 28 Nov 2015 19:36:54 +0100https://ask.sagemath.org/question/31163/enumerate-all-solutions-to-linear-system-over-finite-field/?answer=31164#post-id-31164