Changeset 0d69875 in git


Ignore:
Timestamp:
Jun 29, 1999, 11:05:16 AM (24 years ago)
Author:
Moritz Wenk <wenk@…>
Branches:
(u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
Children:
31cb04bad383e04297522d6946776d17b7452307
Parents:
9a6c4ae84f7d2709f65215910c1238b8642ea6ff
Message:
*wenk: added some ERROR()'s


git-svn-id: file:///usr/local/Singular/svn/trunk@3183 2c84dea3-7e68-4137-9b89-c4e89433aadc
File:
1 edited

Legend:

Unmodified
Added
Removed
  • Singular/LIB/solve.lib

    r9a6c4a r0d69875  
    11///////////////////////////////////////////////////////////////////////////////
    22
    3 version="$Id: solve.lib,v 1.2 1999-06-28 16:48:58 Singular Exp $";
     3version="$Id: solve.lib,v 1.3 1999-06-29 09:05:16 wenk Exp $";
    44info="
    55LIBRARY: solve.lib     PROCEDURES TO SOLVE POLYNOMIAL SYSTEMS
     
    99 mp_res_mat(i,..);      multipolynomial resultant matrix of ideal i
    1010 laguerre_solve(p,..);  find all roots of univariate polynom p
    11  interpolate(i,j,d);    interpolate poly from evaluation points i and results j
     11 interpolate(i,j);      interpolate poly from evaluation points i and results j
    1212";
    1313
     
    1818         k=0: use sparse resultant matrix of Gelfand, Kapranov and Zelevinsky
    1919         k=1: use resultant matrix of Macaulay (k=0 is default)
    20          l>0: defines precision of fractional part if groundfield is Q
     20         l>0: defines precision of fractional part if ground field is Q
    2121         m=0,1,2: number of iterations for approximation of roots (default=2)
    22 ASSUME:  i is a zerodimensional ideal with
    23          nvars(basering) = ncols(i) = number of vars actually occuring in i
     22ASSUME:  i is a zerodimensional ideal with 
     23         nvars(basering) = ncols(i) = number of vars actually occuring in i 
    2424RETURN:  list of all (complex) roots of the polynomial system i = 0,
    25          of type number if the groundfield is the complex numbers,
    26          of type string if the groundfield is the rational or real numbers
     25         of type number if the ground field is the complex numbers,
     26         of type string if the ground field is the rational or real numbers
    2727EXAMPLE: example ures_solve; shows an example
    2828"
    2929{
    30   int typ=2;
     30  int typ=0;
    3131  int polish=2;
    3232  int prec=30;
    3333
    34   if ( size(#) >= 1 )
    35   {
    36     typ= #[1];
    37     if ( typ < 0 || typ > 1 )
    38     {
    39       ERROR("// Valid values for second parameter are:
    40       // 0: use sparse Resultant (default)
    41       // 1: use Macaulay Resultant");
    42     }
    43   }
    44   if ( size(#) >= 2 )
    45   {
    46     prec= #[2];
    47     if ( prec == 0 ) { prec = 30; }
    48     if ( prec < 0 )
    49     {
    50       "// Fourth parameter must be positive!";
    51       return();
    52     }
    53   }
    54   if ( size(#) >= 3 )
    55   {
    56     polish= #[3];
    57     if ( polish < 0 || polish > 3 )
    58     {
    59       "// Valid values for third parameter are: ";
    60       "// 0,1,2: number of iterations for approximation of roots";
    61       return();
    62     }
    63     if ( polish == 0 ) { polish = 3; }
    64   }
    65 
    66   if ( size(#) > 3 )
    67   {
    68     // Error
    69     "// only three parameters allowed!";
    70     return();
    71   }
     34  if ( size(#) >= 1 )
     35    {
     36      typ= #[1];
     37      if ( typ < 0 || typ > 1 )
     38        {
     39          ERROR("Valid values for second parameter k are:
     40          0: use sparse Resultant (default)
     41          1: use Macaulay Resultant");
     42        }
     43    }
     44  if ( size(#) >= 2 )
     45    {
     46      prec= #[2];
     47      if ( prec == 0 ) { prec = 30; }
     48      if ( prec < 0 )
     49        {
     50          ERROR("Third parameter l must be positive!");
     51        }
     52    }
     53  if ( size(#) >= 3 )
     54    {
     55      polish= #[3];
     56      if ( polish < 0 || polish > 2 )
     57        {
     58          ERROR("Valid values for fourth parameter m are:
     59          0,1,2: number of iterations for approximation of roots");
     60        }
     61    }
     62
     63  if ( size(#) > 3 )
     64    {
     65      ERROR("only three parameters allowed!");
     66    }
    7267
    7368  int digits= system("setFloatDigits",prec);
    7469
    7570  return(uressolve(gls,typ,polish));
    76 
     71 
    7772}
    7873example
     
    8681
    8782  pause;
    88   // now with complex coefficient field, precision is 10 digits
     83  // now with complex coefficient field, precision is 10 digits 
    8984  ring rsc= (real,10,I),(x,y),lp;
    90   ideal i = x2 + y2 - 8,x2 + xy + 2y2;
     85  ideal i = x2 + y2 - 8, x2 + xy + 2y2;
    9186  ures_solve(i);
    9287  // result is a list of (x,y)-coordinates of complex numbers
     
    9691proc laguerre_solve( poly f, list # )
    9792"USAGE:   laguerre_solve( p[,l,m]); f poly, l,m integers
    98          l>0: defines precision of fractional part if groundfield is Q
     93         l>0: defines precision of fractional part if ground field is Q
    9994         m=0,1,2: number of iterations for approximation of roots (default=2)
    10095ASSUME:  p is an univariate polynom
     
    10398"
    10499{
    105   int polish=3;
     100  int polish=2;
    106101  int prec=30;
    107102
    108   if ( size(#) >= 1 )
    109   {
    110     prec= #[1];
    111     if ( prec == 0 ) { prec = 30; }
    112     if ( prec < 0 )
    113     {
    114       "// Fisrt parameter must be positive!";
    115       return();
    116     }
    117   }
    118   if ( size(#) >= 2 )
    119   {
    120     polish= #[2];
    121     if ( polish == 0 ) { polish = 3; }
    122     if ( polish < 0 || polish > 2 )
    123     {
    124       "// Valid values for third parameter are: ";
    125       "// 0,1,2: number of iterations for approximation of roots";
    126       return();
    127     }
    128   }
    129   if ( size(#) > 2 )
    130   {
    131     "// only two parameters allowed!";
    132     return();
    133   }
     103  if ( size(#) >= 1 )
     104    {
     105      prec= #[1];
     106      if ( prec == 0 ) { prec = 30; }
     107      if ( prec < 0 )
     108        {
     109          ERROR("Fisrt parameter must be positive!");
     110        }
     111    }
     112  if ( size(#) >= 2 )
     113    {
     114      polish= #[2];
     115      if ( polish < 0 || polish > 2 )
     116        {
     117          ERROR("Valid values for third parameter are:
     118          0,1,2: number of iterations for approximation of roots");
     119        }
     120    }
     121  if ( size(#) > 2 )
     122    {
     123      ERROR("only two parameters allowed!");
     124    }
    134125
    135126  int digits= system("setFloatDigits",prec);
    136127
    137128  return(laguerre(f,polish));
    138 
     129 
    139130}
    140131example
     
    158149///////////////////////////////////////////////////////////////////////////////
    159150
    160 proc mp_res_mat( ideal gls, list # )
     151proc mp_res_mat( ideal i, list # )
    161152"USAGE:   mp_res_mat(i[,k]); i ideal, k integer
    162153         k=0: sparse resultant matrix of Gelfand, Kapranov and Zelevinsky
    163154         k=1: resultant matrix of Macaulay (k=0 is default)
    164155ASSUME:  nvars(basering) = ncols(i)-1 = number of vars actually occuring in i,
    165          for k=1 i must be homogeneous
    166 RETURN:  module representing the multipolynomial resultant matrix
     156         for k=1 i must be homogeneous 
     157RETURN:  module representing the multipolynomial resultant matrix 
    167158EXAMPLE: example mp_res_mat; shows an example
    168159"
     
    170161  int typ=2;
    171162
    172   if ( size(#) == 1 )
    173   {
    174     typ= #[1];
    175     if ( typ == 0 ) { typ = 2; }
    176     if ( typ < 0 || typ > 2 )
    177     {
    178       "// Valid values for third parameter are: ";
    179       "// 0: sparse resultant (default)";
    180       "// 1: Macaulay resultant";
    181       return();
    182     }
    183   }
    184   if ( size(#) > 1 )
    185   {
    186     "// only two parameters allowed!";
    187     return();
    188   }
    189   return(mpresmat(gls,typ));
     163  if ( size(#) == 1 )
     164    {
     165      typ= #[1];
     166      if ( typ < 0 || typ > 1 )
     167        {
     168          ERROR("Valid values for third parameter are:
     169          0: sparse resultant (default)
     170          1: Macaulay resultant");
     171        }
     172    }
     173  if ( size(#) > 1 )
     174    {
     175      ERROR("only two parameters allowed!");
     176    }
     177
     178  return(mpresmat(i,typ));
     179 
    190180}
    191181example
     
    194184  // compute resultant matrix in ring with parameters (sparse resultant matrix)
    195185  ring rsq= (0,u0,u1,u2),(x1,x2),lp;
    196   ideal gls= u0+u1*x1+u2*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;
    197   module m = mp_res_mat(gls);
     186  ideal i= u0+u1*x1+u2*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;
     187  module m = mp_res_mat(i);
    198188  print(m);
    199189  // computing sparse resultant
     
    203193  // compute resultant matrix (Macaulay resultant matrix)
    204194  ring rdq= (0,u0,u1,u2),(x0,x1,x2),lp;
    205   ideal hgls=  homog(imap(rsq,gls),x0);
     195  ideal h=  homog(imap(rsq,i),x0);
    206196  hgls;
    207   module m = mp_res_mat(hgls,1);
     197  module m = mp_res_mat(h,1);
    208198  print(m);
    209199  // computing Macaulay resultant (should be the same as above!)
     
    213203  // compute numerical sparse resultant matrix
    214204  setring rsq;
    215   ideal glsr= 15+2*x1+5*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;
    216   module mn = mp_res_mat(glsr);
     205  ideal ir= 15+2*x1+5*x2,x1^2 + x2^2 - 10,x1^2 + x1*x2 + 2*x2^2 - 16;
     206  module mn = mp_res_mat(ir);
    217207  print(mn);
    218208  // computing sparse resultant
     
    221211///////////////////////////////////////////////////////////////////////////////
    222212
    223 proc interpolate( ideal p, ideal w )
    224 "USAGE:   interpolate(p,v); p,v ideals
    225 ASSUME:  ground field K is the rational or real or complex numbers,
     213proc interpolate( ideal p, ideal w, int d )
     214"USAGE:   interpolate(p,v,d); p,v ideals, d int
     215ASSUME:  ground field K is the rational numbers,
    226216         p and v consist of numbers of the ground filed K, p must have
    227          n elements, v must have N=(d+1)^n elements where n=nvars(basering)
    228          and d=deg(f) (f is the unknown polynomial in K[x1,...,xn])
     217         n elements, v must have N=(d+1)^n elements where n=nvars(basering) 
     218         and d=deg(f) (f is the unknown polynomial in K[x1,...,xn]) 
    229219COMPUTE: polynomial f with values given by v at points p1,..,pN derived from p;
    230220         more precisely: consider p as point in K^n and v as N elements in K,
    231221         let p1,..,pN be the points in K^n obtained by evaluating all monomials
    232          of degree <= d at p in lexicographical order,
     222         of degree 0,1,...,N at p in lexicographical order,
    233223         then the procedure computes the polynomial f satisfying f(pi) = v[i]
    234224RETURN:  polynomial f of degree d
     
    237227"
    238228{
    239   return(vandermonde(p,w));
     229  return(vandermonde(p,w,d));
    240230}
    241231example
     
    244234  ring r1 = 0,(x),lp;
    245235  // First example:
    246   // deg(f) = 4,
     236  // deg(f) = 4, 
    247237  // v = values of f at points 3^0, 3^1, 3^2, 3^3, 3^4
    248238  ideal v=16,0,11376,1046880,85949136;
    249   interpolate( 3, v );
     239  interpolate( 3, v, 4 );
    250240
    251241  ring r2 = 0,(x,y),dp;
    252   // Second example:
     242  // Second example: 
    253243  // deg(f) = 3
    254244  // valuation point (2,3)
     
    256246  ideal p = 2,3;
    257247  ideal v= 1,2,3,4,5,6,7,8,9,10,11,12,13,14,15,16;
    258   interpolate( p,v );
    259 }
    260 ///////////////////////////////////////////////////////////////////////////////
     248  interpolate( p,v,3 );
     249}
     250///////////////////////////////////////////////////////////////////////////////
     251
     252
     253
     254
     255
     256
Note: See TracChangeset for help on using the changeset viewer.