Hello Zach,
first some general remarks concerning the treshold.
Do you want to compute it for plane curves or in the general case or
for hyperplane arrangements?
As far as as I understood, in the two variable case, one wants to
know the resolution graph of singularity since you have to compute
he blowing up of the canonical divisor.
Let me point out that the library alexpoly.lib
http://www.singular.uni-kl.de/Manual/la ... tm#SEC1310 provides the the resolutiongraph.
(So you might not to "re-invent the wheel", although it may be easier to
program the necessary parts on in it own than to understand the code
of somebody else.)
In any case, Singular offers already some useful steps but it has not yet
a single command to compute the treshold. Hence it is worth to implement it.
Now to your question:
as Singular does not have (yet) a datatype rational, you may resp.
have to proceed in a way similar as you have proposed.
Since you ask for global variables, I would store numerators and
denominators seperately in a global intvec and then finally switch
to a ring in char zero to recombine them to rational numbers.
-----------------------------------------------------------------
Each library defines a namespace, derived from its name with
upcased initial letter but without the ending lib.
Supposed your library is called treshold.lib, then this
defines a namespace Treshold.
You may create global variables within this Namespace by
using export
http://www.singular.uni-kl.de/Manual/la ... htm#SEC389 or exportto
http://www.singular.uni-kl.de/Manual/la ... htm#SEC390 The variables within this namespace are somewhat hidden from outside
but can be listed by listvar(Treshold) and accesed by its fully specified
name Treshold::varname.
Note that Sigular 3-1-3 offers to the following feature:
http://www.singular.uni-kl.de:8002/trac/ticket/139 In each library it can be defined a proc mod_init
which will be executed when loading. Here you may ceate
the global variables for the library.
Code:
LIB "treshold.lib";
version = "$Id: treshold.lib$";
category = "Singularities";
info =
"
LIBRARY: treshold.lib, computes the log canonical treshold
"
proc mod_init()
{
intvec Numv; // Numerators
export(Numv);
intvec Denv; // Denominator
export(Denv);
int N; // the length of the intvec
export(N);
}
proc compute_blowup()
{
// Sets three entries of the intvecs
N++;
Numv[N]=1;
Denv[N] = 2;
N++;
Numv[N]=2;
Denv[N] = 3;
N++;
Numv[N]=4;
Denv[N] = 6;
}
proc compute_lct()
{
// def d = basering; // assume we have defined a ring in char 0 outside
number lct;
Numv;
Denv;
number CKratio = lct;
for (int i=1;i<=N;i++)
{
CKratio = number(Numv[i]+1)/Denv[i]; // this cast with number is required !
if (CKratio > lct) {lct = CKratio;}
}
return(lct);
}
An example how it works:
Code:
> ring r=0,(x,y),ds;
> poly f = x2-y3;
> LIB "treshold.lib";
// ** loaded treshold.lib $Id: treshold.lib$
> compute_blowup();
> listvar(Treshold);
// Treshold [0] package (S,treshold.lib)
// ::N [0] int 3
// ::Denv [0] intvec (3)
// ::Numv [0] intvec (3)
// ::compute_lct [0] proc from treshold.lib
// ::compute_blowup [0] proc from treshold.lib
// ::mod_init [0] proc from treshold.lib
> Treshold::Denv;
2,3,6
> Treshold::Numv;
1,2,4
> Treshold::N;
3
> compute_lct( ); // the treshold of the ordinary cusp
5/6
----------------
Christian Gorzel