source: git/Singular/LIB/lll.lib @ a99a04

spielwiese
Last change on this file since a99a04 was a99a04, checked in by Hans Schönemann <hannes@…>, 23 years ago
* hannes: lll.lib git-svn-id: file:///usr/local/Singular/svn/trunk@5338 2c84dea3-7e68-4137-9b89-c4e89433aadc
  • Property mode set to 100644
File size: 2.0 KB
Line 
1///////////////////////////////////////////////////////////////////////////////
2version="$Id: lll.lib,v 1.2 2001-03-26 12:05:00 Singular Exp $";
3category="Commutative Algebra";
4info="
5LIBRARY: LLL.lib      Integral LLL-Algorithm
6AUTHOR:  Alberto Vigneron-Tenorio and Alfredo Sanchez-Navarro
7         email: alberto.vigneron@uca.es, alfredo.sanchez@uca.es
8
9PROCEDURES:
10 LLL(..);   Integral LLL-Algorithm
11";
12
13///////////////////////////////////////////////////////////////////////////////
14proc LLL(list #)
15"The output is a LLL-reduced basis of the lattice of Z^n"
16{
17  // input: list(list(int,...),...)
18  // check arguments as far as necessary
19  // other inconsistencies are detected by the external program
20  int num_of_vect=size(#);
21  if(num_of_vect <=0)
22  { ERROR("no input parameters ?"); }
23  int num_of_coords=size(#[1]);
24
25  // create first temporary file with which the external program is
26  // called
27
28  int process=system("pid");
29  string file="temp_"+string(process);
30  string resfile="res_"+string(process);
31  link l=":w "+file;
32  open(l);
33
34  write(l,string(num_of_vect)+","+string(num_of_coords));
35  int j;
36  list tmp;
37  for(j=1;j<=num_of_vect;j++)
38  {
39    if(size(#[j])!=num_of_coords)
40    { ERROR("mismatch of number of coordinates"); }
41    tmp=#[j];
42    write(l,(tmp)[1..num_of_coords]);
43  }
44  write(l," ");
45
46  close(l);
47
48  // call external program
49  int dummy=system("sh","LLL <"+file+">"+resfile);
50
51  // read solution from created file
52  link SOLUTION=":r "+resfile;
53  string solution=read(SOLUTION);
54
55  // delete all created files
56  if (dummy==0) //return code okay
57  {
58    dummy=system("sh","rm -f "+file+" "+resfile);
59  } 
60  else
61  {
62    ERROR("external program returns "+string(dummy)+newline+
63          "see "+file+" and "+resfile+" for details");
64  }       
65
66  execute(solution); // result is now in list "res"
67  return(res);
68}
69example
70{
71  "EXAMPLE:";echo=2;
72  list l=list(1,-2,4),list(2,1,-7);
73  LLL(l);
74
75///////////////////////////////////////////////////////////////////////////////
Note: See TracBrowser for help on using the repository browser.