Singular
https://www.singular.uni-kl.de/forum/

Global variable for rational number?
https://www.singular.uni-kl.de/forum/viewtopic.php?f=10&t=1927
Page 1 of 1

Author:  zteitler [ Thu May 19, 2011 11:32 am ]
Post subject:  Global variable for rational number?

Hello,

I have a collection of rings (all with rational coefficients), for each of which I can compute a rational number; I would like to compute the minimum of the rational numbers over the list of rings. At the moment I can see two ways to do this: Either compute (and store) the rational number in each of my rings and use 'fetch' to bring them each into a single ring (the first one in the list) for comparison; or, instead of rational numbers, use an intvec of length 2 (numerator, denominator) and use custom routines for comparison (as, for positive integers, p/q > x/y if and only if p*y > x*q).

I would like to ask if there is a more direct or easier way to do this?

Incidentally, my list of rings is the list of charts in a resolution of singularities computed by the desing.lib package, and the rational number I'm computing is the log canonical threshold of the singularity. I hope to complete a package for computing multiplier ideals.

Thanks very much,

Zach Teitler

Author:  gorzel [ Wed May 25, 2011 4:35 pm ]
Post subject:  Re: Global variable for rational number?

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

Author:  zteitler [ Tue May 31, 2011 6:57 am ]
Post subject:  Re: Global variable for rational number?

Dear Christian,

Thank you for your detailed reply. I have for now proceeded to use an intvec containing the numerator and denominator of the rational numbers, together with simple (very simple!) routines for things like comparing or adding rational numbers that are represented in this way. It is not beautiful but it works completely fine.

I was not aware of the alexpoly library and its ability to provide the resolution graph of a plane curve singularity. This is very nice indeed! In fact, I aim to find multiplier ideals of arbitrary ideals, not just plane curve singularities, but nevertheless I am glad to know of this library. So, thank you for alerting me to this.

I entered the simple (canonical?) example f = y^2-x^3. alexpoly easily found the total transform, 2E_1+3E_2+6E_3 (plus strict transform). With the incidence matrix of the exceptional divisors it should be possible to find the relative canonical divisor --- I should know this; but I have to think about it. Then it will be easy to find the threshold. But it does not seem possible to compute multiplier ideals, without having actual equations for the exceptional divisors.

Zach

Author:  levandov [ Fri Oct 14, 2011 7:03 pm ]
Post subject:  Re: Global variable for rational number?

Hi Zach,

I wanted to let you know, that there are some plans to implement algorithms for log-canonical threshold as well as multiplier ideals by the D-module "task force" of Singular, which I am coordinating. We've got already many tools thoroughly implemented, see dmod.lib, dmodapp.lib, bfun.lib and others.

With best regards,
Viktor Levandovskyy

Page 1 of 1 All times are UTC + 1 hour [ DST ]
Powered by phpBB © 2000, 2002, 2005, 2007 phpBB Group
http://www.phpbb.com/