[sage-support] Integer solutions for systems of linear equations

2012-09-11 Thread moritz
Let's consider a system of linear equations with integer coefficients:

n=3
m=5
A=random_matrix(ZZ,n,m)
b=random_vector(ZZ,n)

What is the best way to find an integer vector x such that Ax=b?
A rational solution is of course found by A.solve_right(b). 

A random example:
 
A=matrix(ZZ,3,5,[-1,  0, -1, -1,  1, 0, -2, -1,  1, -8,-1,  0,  2, -8, -2])
b=vector(ZZ,3,[-1,-1,15])

A.solve_right(b) gives (-13/3, -13/6, 16/3, 0, 0), although there are 
integer solutions,
e.g.: (-221, 13, 144, 65, -13)

Is there also a good way to get all integer solutions? In the example above 
that would be something like:

[-10*t0 - 30*t1 - 221, -2*t0 + 3*t1 + 13, 7*t0 + 19*t1 + 144, 3*t0 + 9*t1 + 
65, -2*t1 - 13]

for integer variables t0 and t1.

The best way I could think of is to implement the algorithm from section 
4.5.2 from Knuth's TAOCP. (This is also where the solutions above come from)
Is there a simpler way to do that in sage?

Of course to we could formulate the same question in terms of linear 
equations instead of matrices, but then solve() also gives rational, 
non-integer solutions. 

Maybe the right thing to use would be isolve from maple, but the interface 
is broke ( see http://trac.sagemath.org/sage_trac/ticket/12295 ).

To consider the problem as linear program and use 
MixedIntegerLinearProgram()  with integer constrains works, but it is very 
very slow for larger systems.

Any help will be appreciated,

moritz

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.




[sage-support] Re: Sage 5.2 fails to build (mpir-2.4.0.p6) on Fedora 16 32-bit

2012-09-11 Thread rickhg12hs
On Monday, September 10, 2012 2:16:02 PM UTC-4, rickhg12hs wrote:

 After failing an upgrade from Sage v. 4.8, the Sage v. 5.2 source was 
 downloaded (md5sum checked fine) and the build started.  The build 
 failed with mpir-2.4.0.p6 complaining that configure: error: ABI=32 
 is not among the following valid choices: standard. 


I ran make -k just so the build would continue after the mpir failure and 
another problem was encountered.  Something needing Fedora 16's 
openssl-devel failed and after installing it from the normal Fedora repo 
the only build failure now seems to be mpir.  Fedora 16's mpir is several 
versions older than Sage's 5.2 so I'm wondering if there is just another 
dependency I need to successfully build Sage 5.2.

Any thoughts?

-- 
You received this message because you are subscribed to the Google Groups 
sage-support group.
To post to this group, send email to sage-support@googlegroups.com.
To unsubscribe from this group, send email to 
sage-support+unsubscr...@googlegroups.com.
Visit this group at http://groups.google.com/group/sage-support?hl=en.