File: hilbert.m2

package info (click to toggle)
frobby 0.9.6-1
  • links: PTS, VCS
  • area: main
  • in suites: forky, sid
  • size: 11,616 kB
  • sloc: cpp: 30,134; sh: 1,184; makefile: 306; ansic: 102; lisp: 10
file content (39 lines) | stat: -rw-r--r-- 1,106 bytes parent folder | download | duplicates (4)
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
multiHilbert = id -> (
  gradedRing := varCount -> (
    x := symbol x;
    variables := apply(1..varCount, k -> x_k);
    listApply := args -> toList(apply args);
    makeVector := i -> listApply(1..varCount, k -> if k == i then 1 else 0);
    vectors := listApply(1..varCount, makeVector);
    return ZZ[variables, Degrees=>vectors];
  );

  R := ring id;
  gR := gradedRing(#(gens R));
  toGRMapping := apply(gens R, gens gR, (a, b) -> a => b);
  gHilbert := poincare(sub(id, toGRMapping));

  toRMapping := apply(gens(ring gHilbert), gens R, (a, b) -> a => b);
  return sub(gHilbert, toRMapping);
);

uniHilbert = id -> (
  R := ring id;
  uni := poincare id;
  tR := QQ[t];

  toSmallTMapping := apply(gens(ring uni), gens tR, (a, b) -> a => b);
  return sub(uni, toSmallTMapping);
);

printPoly = (poly, ofile) -> (
  ofile
    << "R = " << describe ring poly << ";" << endl
    << "p = " << toString poly << ";" << endl;
);

printIdeal = (id, ofile) -> (
  ofile
    << "R = " << describe ring id << ";" << endl
    << "I = " << toString id << ";" << endl;
);