A while ago I made a integer row-reduction routine that does the equivalent
of forward elimination for integer matrices:
rowreduceint=:3 :0
if. 0=*/$y do. y return. end.
y=.(* <:@+:@(>&0)@{."1) y
n=.+/*{."1 y
if. n=0 do. 0,.rowreduceint }."1 y return. end.
while. n>1 do.
i=.(i.<./) (+ _*=&0) {."1 y
y=.y - (i{y)*/~ 0 i} (<....@% i&{) {."1 y
n=.+/*{."1 y
end.
y=. \:~ y
({.y) , 0,. rowreduceint 1 1}. y
)
You could run this on the extended matrix A|y as a start to solving the
integer equation Ax=y . Then you would have to find a good way to do
back-substitution, because it will not work perfectly with integer matrices.
Marshall
-----Original Message-----
From: [email protected]
[mailto:[email protected]] On Behalf Of Justin Paston-Cooper
Sent: Sunday, December 12, 2010 3:18 AM
To: Programming forum
Subject: [Jprogramming] Solving diophantine equations
Hello,
Could anyone please tell me what facilities there are for J for solving
diophantine equations? Specifically, I have square integer matrices A of
rank n, and I want to find integer vectors x of length n such that xA = y
(another integer vector) and x.x = z (an integer).
I'll also have cases where it is useful to find scalars z with xAx = z. Have
such packages been written for J? Should I be looking somewhere else? I've
been working with Mathematica, and it hasn't been particularly fast.
Thanks in advance,
Justin
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm
----------------------------------------------------------------------
For information about J forums see http://www.jsoftware.com/forums.htm