/////////////////////////////////////////////////////////////////////////////// version="\$Id\$"; category="Commutative Algebra"; info=" LIBRARY: LLL.lib Integral LLL-Algorithm AUTHOR: Alberto Vigneron-Tenorio and Alfredo Sanchez-Navarro email: alberto.vigneron@uca.es, alfredo.sanchez@uca.es PROCEDURES: LLL(..); Integral LLL-Algorithm "; /////////////////////////////////////////////////////////////////////////////// proc LLL(list #) "The output is a LLL-reduced basis of the lattice of Z^n" { // input: list(list(int,...),...) // check arguments as far as necessary // other inconsistencies are detected by the external program int num_of_vect=size(#); if(num_of_vect <=0) { ERROR("no input parameters ?"); } int num_of_coords=size(#[1]); // create first temporary file with which the external program is // called int process=system("pid"); string file="temp_"+string(process); string resfile="res_"+string(process); link l=":w "+file; open(l); write(l,string(num_of_vect)+","+string(num_of_coords)); int j; list tmp; for(j=1;j<=num_of_vect;j++) { if(size(#[j])!=num_of_coords) { ERROR("mismatch of number of coordinates"); } tmp=#[j]; write(l,(tmp)[1..num_of_coords]); } write(l," "); close(l); // call external program int dummy=system("sh","LLL <"+file+">"+resfile); // read solution from created file link SOLUTION=":r "+resfile; string solution=read(SOLUTION); // delete all created files if (dummy==0) //return code okay { dummy=system("sh","rm -f "+file+" "+resfile); } else { ERROR("external program returns "+string(dummy)+newline+ "see "+file+" and "+resfile+" for details"); } execute(solution); // result is now in list "res" return(res); } example { "EXAMPLE:";echo=2; list l=list(1,-2,4),list(2,1,-7); LLL(l); } ///////////////////////////////////////////////////////////////////////////////