Changeset 2a4de8 in git


Ignore:
Timestamp:
May 7, 2007, 7:00:36 PM (16 years ago)
Author:
Hans Schönemann <hannes@…>
Branches:
(u'spielwiese', 'd1ba061a762c62d3a25159d8da8b6e17332291fa')
Children:
4bebba7353438f052b4ad581ede34fa6f31e5a71
Parents:
3332cc62f3084f897a059b454c1a0aaff2be7c9a
Message:
*hannes: format


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

Legend:

Unmodified
Added
Removed
  • Singular/LIB/solve.lib

    r3332cc6 r2a4de8  
    11///////////////////////////////////////////////////////////////////////////////
    2 version="$Id: solve.lib,v 1.35 2006-07-18 15:22:15 Singular Exp $";
     2version="$Id: solve.lib,v 1.36 2007-05-07 17:00:36 Singular Exp $";
    33category="Symbolic-numerical solving";
    44info="
     
    570570  {
    571571    int sofar=1;
    572     if (typeof(#[1])=="int"){
     572    if (typeof(#[1])=="int")
     573    {
    573574      outprec = #[1];
    574575      if (outprec<4){outprec = 4;}
    575       if (size(#)>1){
    576         if (typeof(#[2])=="int"){
     576      if (size(#)>1)
     577      {
     578        if (typeof(#[2])=="int")
     579        {
    577580          mu = #[2];
    578           if (size(#)>2){
    579             if (typeof(#[3])=="int"){
     581          if (size(#)>2)
     582          {
     583            if (typeof(#[3])=="int")
     584            {
    580585              prec = #[3];
    581586              if (prec<8){prec = 8;}
    582587            }
    583             else {
     588            else
     589            {
    584590              if(mu!=0){prec = 60;}
    585591              if (#[3]=="oldring"){ oldr=1; }
     
    589595          }
    590596        }
    591         else {
     597        else
     598        {
    592599          if (#[2]=="oldring"){ oldr=1; }
    593600          if (#[2]=="nodisplay"){ nodisp=1; }
     
    596603      }
    597604    }
    598     else {
     605    else
     606    {
    599607      if (#[1]=="oldring"){ oldr=1; }
    600608      if (#[1]=="nodisplay"){ nodisp=1; }
    601609    }
    602     for (ii=sofar+1;ii<=size(#);ii++) { // check for additional strings
    603        if (typeof(#[ii])=="string")
    604        {
    605           if (#[ii]=="oldring"){ oldr=1; }
    606           if (#[ii]=="nodisplay"){ nodisp=1; }
    607        }
     610    for (ii=sofar+1;ii<=size(#);ii++)
     611    { // check for additional strings
     612      if (typeof(#[ii])=="string")
     613      {
     614        if (#[ii]=="oldring"){ oldr=1; }
     615        if (#[ii]=="nodisplay"){ nodisp=1; }
     616      }
    608617    }
    609618  }
     
    617626    for (ii=1;ii<=size(LL);ii++)
    618627    {
    619       if (typeof(`LL[ii]`)=="ring") {
    620         if (find(charstr(`LL[ii]`),"complex,"+string(outprec))){
     628      if (typeof(`LL[ii]`)=="ring")
     629      {
     630        if (find(charstr(`LL[ii]`),"complex,"+string(outprec)))
     631        {
    621632          jj++;
    622633          Out[jj]=LL[ii];
     
    624635      }
    625636    }
    626     if (size(Out)>0) {
     637    if (size(Out)>0)
     638    {
    627639      print("// *** You may select between the following rings for storing "+
    628640            "the list of");
     
    634646      while (chosen=="") { chosen=read(""); }
    635647      execute("def tchosen = "+chosen);
    636       if (typeof(tchosen)=="int") {
    637         if ((tchosen>0) and (tchosen<=size(Out))) {
     648      if (typeof(tchosen)=="int")
     649      {
     650        if ((tchosen>0) and (tchosen<=size(Out)))
     651        {
    638652          string outR = Out[tchosen];
    639653          print("// *** You have chosen the ring "+ outR +". In this ring"
     
    648662      }
    649663    }
    650     else {
     664    else
     665    {
    651666      print("No appropriate ring for storing the list of solutions found " +
    652667             "=> new ring created and returned");
     
    683698      int vdG=vdim(G);
    684699    }
    685     if (oldr!=1) {
     700    if (oldr!=1)
     701    {
    686702      execute("ring rinC =(complex,"+string(outprec)+
    687703                 "),("+varstr(basering)+"),lp;");
     
    700716      return(rinC);
    701717    }
    702     else {
     718    else
     719    {
    703720      setring (Top::`outR`);
    704721      list SOL;
     
    715732
    716733// look for reduced standard basis in lex
    717   if (sb*lp==0) {
    718     if (sb==0) {
     734  if (sb*lp==0)
     735  {
     736    if (sb==0)
     737    {
    719738      execute("ring dphilb=("+charstr(rin)+"),("+ varstr(rin)+"),dp;");
    720739      ideal G = imap(rin,G);
     
    722741      if (dim(G)!=0){ERROR("ideal not zero-dimensional");}
    723742    }
    724     else {
     743    else
     744    {
    725745      def dphilb = basering;
    726746      G=interred(G);
     
    733753    H = simplify(H,2);
    734754    if (lp){setring rin;}
    735     else {
    736       execute("ring lplex=("+charstr(rin)+"),("+
    737       varstr(rin)+"),lp;");
     755    else
     756    {
     757      execute("ring lplex=("+charstr(rin)+"),("+varstr(rin)+"),lp;");
    738758    }
    739759    ideal H = imap(lexhilb,H);
     
    744764// only 1 variable
    745765  def hr = basering;
    746   if (nv==1) {
    747     if ((mu==0) and (charstr(basering)[1]=="0")) { // special case
     766  if (nv==1)
     767  {
     768    if ((mu==0) and (charstr(basering)[1]=="0"))
     769    { // special case
    748770      list L = laguerre_solve(H[1],prec,prec,mu,0); // list of strings
    749       if (oldr!=1) {
    750         execute("ring rinC =(complex,"+string(outprec)+
    751                    "),("+varstr(basering)+"),lp;");
     771      if (oldr!=1)
     772      {
     773        execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;");
    752774        list SOL;
    753775        for (ii=1; ii<=size(L); ii++ ) { execute("SOL[ii]="+L[ii]+";"); }
     
    763785        return(rinC);
    764786      }
    765       else {
     787      else
     788      {
    766789        setring (Top::`outR`);
    767790        list SOL;
     
    775798      }
    776799    }
    777     else {
    778       execute("ring internC=(complex,"+string(prec)+
    779                  "),("+varstr(basering)+"),lp;");
     800    else
     801    {
     802      execute("ring internC=(complex,"+string(prec)+"),("+varstr(basering)+"),lp;");
    780803      ideal H = imap(hr,H);
    781804      list sp = splittolist(splitsqrfree(H[1],var(1)));
     
    787810      }
    788811      setring hr;
    789       if (oldr!=1) {
    790         execute("ring rinC =(complex,"+string(outprec)+
    791                  "),("+varstr(basering)+"),lp;");
     812      if (oldr!=1)
     813      {
     814        execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;");
    792815        list SOL;
    793816        list sp=imap(internC,sp);
    794817        if(mu!=0){ SOL=sp; }
    795         else {
     818        else
     819        {
    796820          jj = size(sp);
    797821          SOL=sp[jj][1];
    798           while(jj>1) {
     822          while(jj>1)
     823          {
    799824            jj--;
    800825            SOL = sp[jj][1]+SOL;
     
    812837        return(rinC);
    813838      }
    814       else {
     839      else
     840      {
    815841        setring (Top::`outR`);
    816842        list SOL;
    817843        list sp=imap(internC,sp);
    818844        if(mu!=0){ SOL=sp; }
    819         else {
     845        else
     846        {
    820847          jj = size(sp);
    821848          SOL=sp[jj][1];
    822           while(jj>1) {
     849          while(jj>1)
     850          {
    823851            jj--;
    824852            SOL = sp[jj][1]+SOL;
     
    836864  }
    837865
    838 
    839866// the triangular sets (not univariate case)
    840867  attrib(H,"isSB",1);
     
    851878  if (outprec<prec)
    852879  {
    853     execute("ring internC=(complex,"+string(prec)+
    854             "),("+varstr(hr)+"),lp;");
     880    execute("ring internC=(complex,"+string(prec)+"),("+varstr(hr)+"),lp;");
    855881  }
    856882  else
    857883  {
    858     execute("ring rinC =(complex,"+string(outprec)+
    859                  "),("+varstr(basering)+"),lp;");
     884    execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;");
    860885  }
    861886  list triC = imap(hr,sp);
     
    886911// final computations
    887912  option(set,ovec);
    888   if (outprec==prec) { // we are in ring rinC
    889     if (oldr!=1) {
     913  if (outprec==prec)
     914  { // we are in ring rinC
     915    if (oldr!=1)
     916    {
    890917      list SOL=ret1;
    891918      export SOL;
     
    899926      return(rinC);
    900927    }
    901     else {
     928    else
     929    {
    902930      setring (Top::`outR`);
    903931      list SOL=imap(rinC,ret1);
     
    909937    }
    910938  }
    911   else {
    912     if (oldr!=1) {
    913       execute("ring rinC =(complex,"+string(outprec)+
    914                  "),("+varstr(basering)+"),lp;");
     939  else
     940  {
     941    if (oldr!=1)
     942    {
     943      execute("ring rinC =(complex,"+string(outprec)+"),("+varstr(basering)+"),lp;");
    915944      list SOL=imap(internC,ret1);
    916945      export SOL;
     
    924953      return(rinC);
    925954    }
    926     else {
     955    else
     956    {
    927957      setring (Top::`outR`);
    928958      list SOL=imap(internC,ret1);
     
    10191049    }
    10201050    attrib(re,"isSB",1);
    1021     k = size(reduce(A,re));
     1051    k = size(reduce(A,re,1));
    10221052    if (k){return(i);}
    10231053  }
     
    13731403"
    13741404{
    1375     int typ=0;// defaults
    1376     int prec=30;
    1377 
    1378     if ( size(#) > 0 )
    1379     {
    1380         typ= #[1];
    1381         if ( typ < 0 || typ > 1 )
    1382         {
    1383             ERROR("Valid values for second parameter k are:
     1405  int typ=0;// defaults
     1406  int prec=30;
     1407
     1408  if ( size(#) > 0 )
     1409  {
     1410    typ= #[1];
     1411    if ( typ < 0 || typ > 1 )
     1412    {
     1413      ERROR("Valid values for second parameter k are:
    13841414                   0: use sparse Resultant (default)
    13851415                   1: use Macaulay Resultant");
    1386         }
    1387     }
    1388     if ( size(#) > 1 )
    1389     {
    1390         prec= #[2];
    1391         if ( prec < 8 )
    1392         {
    1393             prec = 8;
    1394         }
    1395     }
    1396 
    1397     list LL=uressolve(gls,typ,prec,1);
    1398     int sizeLL=size(LL);
    1399     if (sizeLL==0) {
    1400       dbprint(printlevel-voice+3,"No solution found!");
    1401       return(list());
    1402     }
    1403     if (typeof(LL[1][1])=="string") {
    1404       int ii,jj;
    1405       int nv=size(LL[1]);
    1406       execute("ring rinC =(complex,"+string(prec)+",I),("
     1416    }
     1417  }
     1418  if ( size(#) > 1 )
     1419  {
     1420    prec= #[2];
     1421    if ( prec < 8 )
     1422    {
     1423      prec = 8;
     1424    }
     1425  }
     1426
     1427  list LL=uressolve(gls,typ,prec,1);
     1428  int sizeLL=size(LL);
     1429  if (sizeLL==0)
     1430  {
     1431    dbprint(printlevel-voice+3,"No solution found!");
     1432    return(list());
     1433  }
     1434  if (typeof(LL[1][1])=="string")
     1435  {
     1436    int ii,jj;
     1437    int nv=size(LL[1]);
     1438    execute("ring rinC =(complex,"+string(prec)+",I),("
    14071439                           +varstr(basering)+"),lp;");
    1408       list SOL,SOLnew;
    1409       for (ii=1; ii<=sizeLL; ii++) {
    1410         SOLnew=list();
    1411         for (jj=1; jj<=nv; jj++) {
    1412           execute("SOLnew["+string(jj)+"]="+LL[ii][jj]+";");
    1413         }
    1414         SOL[ii]=SOLnew;
    1415       }
    1416       kill SOLnew;
    1417       export SOL;
    1418       dbprint( printlevel-voice+3,"
     1440    list SOL,SOLnew;
     1441    for (ii=1; ii<=sizeLL; ii++)
     1442    {
     1443      SOLnew=list();
     1444      for (jj=1; jj<=nv; jj++)
     1445      {
     1446        execute("SOLnew["+string(jj)+"]="+LL[ii][jj]+";");
     1447      }
     1448      SOL[ii]=SOLnew;
     1449    }
     1450    kill SOLnew;
     1451    export SOL;
     1452    dbprint( printlevel-voice+3,"
    14191453// 'ures_solve' created a ring, in which a list SOL of numbers (the complex
    14201454// solutions) is stored.
     
    14221456// to the return value):
    14231457        setring R; SOL; ");
    1424       return(rinC);
    1425     }
    1426     else {
    1427       return(LL);
    1428     }
     1458    return(rinC);
     1459  }
     1460  else
     1461  {
     1462    return(LL);
     1463  }
    14291464}
    14301465example
     
    14501485"
    14511486{
    1452     int typ=0;
    1453 
    1454     if ( size(#) > 0 )
    1455     {
    1456         typ= #[1];
    1457         if ( typ < 0 || typ > 1 )
    1458         {
    1459             ERROR("Valid values for third parameter are:
     1487  int typ=0;
     1488
     1489  if ( size(#) > 0 )
     1490  {
     1491    typ= #[1];
     1492    if ( typ < 0 || typ > 1 )
     1493    {
     1494      ERROR("Valid values for third parameter are:
    14601495                   0: sparse resultant (default)
    14611496                   1: Macaulay resultant");
    1462         }
    1463     }
    1464 
    1465     return(mpresmat(i,typ));
    1466 
     1497    }
     1498  }
     1499  return(mpresmat(i,typ));
    14671500}
    14681501example
Note: See TracChangeset for help on using the changeset viewer.