I have written following Lattice Reduction Algorithm. However, it does not work properly (does not matche with the LLL algorithm implemented in Sage). It will be great for me if any one check the program.
# LLL Algorithm M=matrix(ZZ,4,4, [1,57,67,75, 3,4,98,98, 34,23,267,111, 6,134,125,68 ]) print M.LLL(),'Actual' print '----------------------------- -----------' s=0 M1=matrix(QQ,4,4, [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]) M2=matrix(QQ,4,4, [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]) len=4 while(1): M1=matrix(QQ,4,4, [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]) M1[0]=M[0] #print 'ddddd',d for i in range(1,len): M11=matrix(QQ,4,4, [0,0,0,0, 0,0,0,0, 0,0,0,0, 0,0,0,0]) for j in range(i): y=(M[i]*M1[j])/(M1[j]*M1[j]) #print y #M2[i,j]=y #print y*M1[j] #print M11 M11[0]=M11[0] + y*M1[j] M1[i]=M[i]-M11[0] #print M1[i] for i in range(1,len): j=i-1 while(j>=0): M[i]=M[i]-round(M[i]*M1[j]/(M1[j]*M1[j]))*M[j] j=j-1 #print '------------------------------' #print M #print '--------------------------------' for i in range(0,len-1): x=(3/4)*M1[i]*M1[i] #print x y=(M[i+1]*M1[i]/(M1[i]*M1[i]))*M1[i]+M1[i+1] y=y*y d=1 if(x > y): c=M[i] M[i]=M[i+1] M[i+1]=c d=0 break #print 'YES',d if(d==0): continue else: break print M -- 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 For more options, visit this group at http://groups.google.com/group/sage-support URL: http://www.sagemath.org