File: app_lattice.cpp

package info (click to toggle)
gfan 0.5%2Bdfsg-6
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 8,348 kB
  • ctags: 5,683
  • sloc: cpp: 39,675; makefile: 454; sh: 1
file content (78 lines) | stat: -rw-r--r-- 1,572 bytes parent folder | download | duplicates (2)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
#include "vektor.h"
#include "printer.h"
#include "parser.h"
#include "gfanapplication.h"
#include "binomial.h"
#include "latticeideal.h"
#include "field_rationals.h"
#include "lll.h"
#include "linalg.h"

class LatticeApplication : public GFanApplication
{
public:
  bool includeInDefaultInstallation()
  {
    return false;
  }
  LatticeApplication()
  {
    registerOptions();
  }
  const char *name()
  {
    return "_lattice";
  }
  int main()
  {
    FileParser p(Stdin);

    IntegerVectorList ivl=p.parseIntegerVectorList();
    IntegerMatrix A=rowsToIntegerMatrix(ivl);//.transposed();

    AsciiPrinter P(stdout);

    fprintf(Stdout,"Input matrix:\n");
    P.printVectorList(A.getRows());


    fprintf(Stdout,"Hermite normal form matrix:\n");
    FieldMatrix Af=integerMatrixToFieldMatrix(A,Q);
    Af.reduce(false,true);
    Af.printMatrix(P);


    fprintf(Stdout,"LLL-Reduced matrix:\n");


    IntegerMatrix B2=A;
    IntegerMatrix M=mlll(B2);


    P.printVectorList(B2.getRows());


    fprintf(Stdout,"Performed transformation:\n");
    P.printVectorList(M.getRows());

    int kerdim=0;
    while((kerdim<A.getHeight())&&(B2[kerdim].isZero()))
      kerdim++;

    IntegerMatrix ret(kerdim,A.getHeight());

    for(int i=0;i<kerdim;i++)
      ret[i]=M[i];

    fprintf(Stdout,"Lattice Kernel:\n");
    P.printVectorList(ret.getRows());

    return 0;
  }
  const char *helpText()
  {
    return "This program computes various information about the lattice generated by the rows of the input matrix.\n";
  }
};

static LatticeApplication theApplication;