Changeset b117e8 in git


Ignore:
Timestamp:
Dec 8, 2010, 2:32:40 PM (13 years ago)
Author:
Hans Schoenemann <hannes@…>
Branches:
(u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
Children:
295381803a15fde881a84dc11a8d6d1d54928bbe
Parents:
7bb84340b18ebdceb1da60ecdc6f63892358f449
Message:
blackbox types

git-svn-id: file:///usr/local/Singular/svn/trunk@13737 2c84dea3-7e68-4137-9b89-c4e89433aadc
Location:
Singular
Files:
7 edited

Legend:

Unmodified
Added
Removed
  • Singular/Makefile.in

    r7bb8434 rb117e8  
    173173# normal C++ source files
    174174CXXSOURCES=grammar.cc scanner.cc attrib.cc \
    175     eigenval_ip.cc\
     175    blackbox.cc eigenval_ip.cc\
    176176    extra.cc fehelp.cc feOpt.cc \
    177177    ipassign.cc ipconv.cc ipid.cc iplib.cc \
     
    190190    Minor.cc \
    191191    MinorProcessor.cc \
    192     MinorInterface.cc
     192    MinorInterface.cc \
     193    bigintm.cc
    193194
    194195# stuff for MP
     
    238239        mpsr_Put.h walk.h\
    239240        dbm_sl.h libparse.h pipeLink.h \
    240         gms.h pcv.h eigenval_ip.h \
     241        gms.h pcv.h eigenval_ip.h blackbox.h \
    241242        distrib.h walk.h \
    242243        static.h \
  • Singular/extra.cc

    r7bb8434 rb117e8  
    1616#include <kernel/mod2.h>
    1717#include <misc_ip.h>
     18#include <blackbox.h>
    1819
    1920#ifdef TIME_WITH_SYS_TIME
     
    36683669  }
    36693670  else
    3670    
    36713671#endif
     3672/*==================== listing all blackbox types (debug stuff) =========*/
     3673  if(strcmp(sys_cmd,"blackbox")==0)
     3674  {
     3675    printBlackboxTypes();
     3676    return FALSE;
     3677  }
     3678  else
    36723679/*==================== Error =================*/
    36733680      Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
  • Singular/iparith.cc

    r7bb8434 rb117e8  
    6969#include <Singular/ipshell.h>
    7070#include <kernel/mpr_inout.h>
     71#include <Singular/blackbox.h>
    7172
    7273#ifdef HAVE_FANS
     
    32713272}
    32723273static BOOLEAN jjINTERSC(leftv res, leftv u, leftv v)
    3273 { 
     3274{
    32743275  gfan::ZCone* zc1 = (gfan::ZCone*)u->Data();
    32753276  gfan::ZCone* zc2 = (gfan::ZCone*)v->Data();
     
    34773478static BOOLEAN jjINSERTCONE(leftv res, leftv u, leftv v)
    34783479{
    3479         gfan::ZFan* zf = (gfan::ZFan*)u->Data();
    3480         gfan::ZCone* zc = (gfan::ZCone*)v->Data();
    3481         zf->insert(*zc);
    3482         return FALSE;
     3480        gfan::ZFan* zf = (gfan::ZFan*)u->Data();
     3481        gfan::ZCone* zc = (gfan::ZCone*)v->Data();
     3482        zf->insert(*zc);
     3483        return FALSE;
    34833484}
    34843485static BOOLEAN jjGETPROPC(leftv res, leftv u, leftv v)
     
    50105011static BOOLEAN jjTYPEOF(leftv res, leftv v)
    50115012{
    5012   switch ((int)(long)v->data)
     5013  int t=(int)(long)v->data;
     5014  switch (t)
    50135015  {
    50145016    case INT_CMD:        res->data=omStrDup("int"); break;
     
    50375039    case DEF_CMD:
    50385040    case NONE:           res->data=omStrDup("none"); break;
    5039     default:             res->data=omStrDup("?unknown type?");
     5041    default:
     5042    {
     5043      if (t>MAX_TOK)
     5044        res->data=omStrDup(getBlackboxName(t));
     5045      else
     5046        res->data=omStrDup("?unknown type?");
     5047      break;
     5048    }
    50405049  }
    50415050  return FALSE;
     
    51165125static gfan::IntMatrix permutationIntMatrix(const intvec* iv)
    51175126{
    5118         int cc = iv->cols();
    5119         int rr = iv->rows();
    5120         intvec* ivCopy = new intvec(rr, cc, 0);
    5121         for (int r = 1; r <= rr; r++)
    5122           for (int c = 1; c <= cc; c++)
    5123             IMATELEM(*ivCopy, r, c) = IMATELEM(*iv, r, c) - 1;
    5124         gfan::ZMatrix zm = intmat2ZMatrix(ivCopy);
    5125         gfan::IntMatrix* im = new gfan::IntMatrix(gfan::ZToIntMatrix(zm));
    5126         return *im;
     5127        int cc = iv->cols();
     5128        int rr = iv->rows();
     5129        intvec* ivCopy = new intvec(rr, cc, 0);
     5130        for (int r = 1; r <= rr; r++)
     5131          for (int c = 1; c <= cc; c++)
     5132            IMATELEM(*ivCopy, r, c) = IMATELEM(*iv, r, c) - 1;
     5133        gfan::ZMatrix zm = intmat2ZMatrix(ivCopy);
     5134        gfan::IntMatrix* im = new gfan::IntMatrix(gfan::ZToIntMatrix(zm));
     5135        return *im;
    51275136}
    51285137static BOOLEAN jjFANEMPTY_I(leftv res, leftv v)
    51295138{
    5130         int ambientDim = (int)(long)v->Data();
    5131         if (ambientDim < 0)
    5132         {
    5133           Werror("expected non-negative ambient dim but got %d", ambientDim);
    5134           return TRUE;
    5135         }
    5136         res->data = (char*)(new gfan::ZFan(ambientDim));
    5137         return FALSE;
     5139        int ambientDim = (int)(long)v->Data();
     5140        if (ambientDim < 0)
     5141        {
     5142          Werror("expected non-negative ambient dim but got %d", ambientDim);
     5143          return TRUE;
     5144        }
     5145        res->data = (char*)(new gfan::ZFan(ambientDim));
     5146        return FALSE;
    51385147}
    51395148static BOOLEAN jjFANEMPTY_IM(leftv res, leftv v)
    51405149{
    5141         intvec* permutations = (intvec*)v->Data();
    5142         int ambientDim = permutations->cols();
    5143         gfan::IntMatrix im = permutationIntMatrix(permutations);
    5144         if (!gfan::Permutation::arePermutations(im))
    5145         {
    5146                 Werror("provided intmat contains invalid permutations of {1, ..., %d}", ambientDim);
    5147                 return TRUE;
    5148         }
    5149         gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
    5150         sg.computeClosure(im);
    5151         res->data = (char*)(new gfan::ZFan(sg));
    5152         return FALSE;
     5150        intvec* permutations = (intvec*)v->Data();
     5151        int ambientDim = permutations->cols();
     5152        gfan::IntMatrix im = permutationIntMatrix(permutations);
     5153        if (!gfan::Permutation::arePermutations(im))
     5154        {
     5155                Werror("provided intmat contains invalid permutations of {1, ..., %d}", ambientDim);
     5156                return TRUE;
     5157        }
     5158        gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
     5159        sg.computeClosure(im);
     5160        res->data = (char*)(new gfan::ZFan(sg));
     5161        return FALSE;
    51535162}
    51545163static BOOLEAN jjFANFULL_I(leftv res, leftv v)
    51555164{
    5156         int ambientDim = (int)(long)v->Data();
    5157         if (ambientDim < 0)
    5158         {
    5159           Werror("expected non-negative ambient dim but got %d", ambientDim);
    5160           return TRUE;
    5161         }
    5162         gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(ambientDim));
    5163         res->data = (char*)zf;
    5164         return FALSE;
     5165        int ambientDim = (int)(long)v->Data();
     5166        if (ambientDim < 0)
     5167        {
     5168          Werror("expected non-negative ambient dim but got %d", ambientDim);
     5169          return TRUE;
     5170        }
     5171        gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(ambientDim));
     5172        res->data = (char*)zf;
     5173        return FALSE;
    51655174}
    51665175static BOOLEAN jjFANFULL_IM(leftv res, leftv v)
    51675176{
    5168         intvec* permutations = (intvec*)v->Data();
    5169         int ambientDim = permutations->cols();
    5170         gfan::IntMatrix im = permutationIntMatrix(permutations);
    5171         if (!gfan::Permutation::arePermutations(im))
    5172         {
    5173                 Werror("provided intmat contains invalid permutations of {1, ..., %d}", ambientDim);
    5174                 return TRUE;
    5175         }
    5176         gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
    5177         sg.computeClosure(im);
    5178         gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(sg));
    5179         res->data = (char*)zf;
    5180         return FALSE;
     5177        intvec* permutations = (intvec*)v->Data();
     5178        int ambientDim = permutations->cols();
     5179        gfan::IntMatrix im = permutationIntMatrix(permutations);
     5180        if (!gfan::Permutation::arePermutations(im))
     5181        {
     5182                Werror("provided intmat contains invalid permutations of {1, ..., %d}", ambientDim);
     5183                return TRUE;
     5184        }
     5185        gfan::SymmetryGroup sg = gfan::SymmetryGroup(ambientDim);
     5186        sg.computeClosure(im);
     5187        gfan::ZFan* zf = new gfan::ZFan(gfan::ZFan::fullFan(sg));
     5188        res->data = (char*)zf;
     5189        return FALSE;
    51815190}
    51825191static BOOLEAN jjCONERAYS1(leftv res, leftv v)
     
    54425451        case (int)jjDIM_R:        dArith1[i].p=(proc1)syDim; break;
    54435452        case (int)jjidTransp:     dArith1[i].p=(proc1)idTransp; break;
    5444 #ifdef GENTABLE
    54455453        default: Werror("missing proc1-definition for %d",(int)(long)dArith1[i].p);
    5446 #endif
    54475454      }
    54485455    }
     
    80378044#endif
    80388045    int at=a->Typ();
     8046    if (at>MAX_TOK)
     8047    {
     8048      blackbox *bb=getBlackboxStuff(at);
     8049      if (bb!=NULL) return bb->blackbox_Op2(op,res,a,b);
     8050      else          return TRUE;
     8051    }
    80398052    int bt=b->Typ();
    80408053    int i=iiTabIndex(dArithTab2,JJTAB2LEN,op);
     
    82508263#endif
    82518264    int at=a->Typ();
     8265    if (at>MAX_TOK)
     8266    {
     8267      blackbox *bb=getBlackboxStuff(at);
     8268      if (bb!=NULL) return bb->blackbox_Op1(op,res,a);
     8269      else          return TRUE;
     8270    }
     8271
    82528272    BOOLEAN failed=FALSE;
    8253 
    82548273    iiOp=op;
    82558274    int i=iiTabIndex(dArithTab1,JJTAB1LEN,op);
     
    84498468#endif
    84508469    int at=a->Typ();
     8470    if (at>MAX_TOK)
     8471    {
     8472      blackbox *bb=getBlackboxStuff(at);
     8473      if (bb!=NULL) return bb->blackbox_Op3(op,res,a,b,c);
     8474      else          return TRUE;
     8475    }
    84518476    int bt=b->Typ();
    84528477    int ct=c->Typ();
     
    86998724    }
    87008725#endif
     8726    if ((a!=NULL) && (a->Typ()>MAX_TOK))
     8727    {
     8728      blackbox *bb=getBlackboxStuff(a->Typ());
     8729      if (bb!=NULL) return bb->blackbox_OpM(op,res,a);
     8730      else          return TRUE;
     8731    }
    87018732    BOOLEAN failed=FALSE;
    87028733    int args=0;
     
    87988829      else
    87998830      {
    8800         return 0;
     8831        // -- blackbox extensions:
     8832        // return 0;
     8833        return blackboxIsCmd(n,tok);
    88018834      }
    88028835    }
     
    89058938  //if (tok==PRINT_EXPR) return "print_expr";
    89068939  if (tok==IDHDL) return "identifier";
     8940  if (tok>MAX_TOK) return getBlackboxName(tok);
    89078941  for(i=0; i<sArithBase.nCmdUsed; i++)
    89088942    //while (sArithBase.sCmds[i].tokval!=0)
  • Singular/ipassign.cc

    r7bb8434 rb117e8  
    4040#include <Singular/ipshell.h>
    4141#include <kernel/sca.h>
     42#include <Singular/blackbox.h>
    4243
    4344#ifdef HAVE_FANS
     
    766767  if ((l->rtyp==IDHDL)&&(lt!=QRING_CMD)&&(lt!=RING_CMD))
    767768    ld=(leftv)l->data;
     769  if (lt>MAX_TOK)
     770  {
     771    blackbox *bb=getBlackboxStuff(lt);
     772    Print("bb-assign: bb=%lx\n",bb);
     773    return (bb==NULL) || bb->blackbox_Assign(l,r);
     774  }
    768775  while (((dAssign[i].res!=lt)
    769776      || (dAssign[i].arg!=rt))
  • Singular/ipid.cc

    r7bb8434 rb117e8  
    2929#include <kernel/syz.h>
    3030#include <Singular/ipid.h>
     31#include <Singular/blackbox.h>
    3132
    3233#ifdef HAVE_FANS
     
    124125  //printf("define %s, %x, lev: %d, typ: %d\n", s,s,lev,t);
    125126  idhdl h = (idrec *)omAlloc0Bin(idrec_bin);
    126   int   len = 0;
    127127  IDID(h)   = s;
    128128  IDTYP(h)  = t;
     
    156156        break;
    157157      case STRING_CMD:
    158         len=1;
     158        IDSTRING(h) = (char *)omAlloc0(1);
    159159        break;
    160160      case LIST_CMD:
     
    176176        //the types with the standard init: set the struct to zero
    177177      case RESOLUTION_CMD:
    178         len=sizeof(ssyStrategy);
     178        IDSTRING(h) = (char *)omAlloc0(sizeof(ssyStrategy));
    179179        break;
    180180    //other types: without init (int,script,poly,def,package)
    181     }
    182     if (len!=0)
    183     {
    184       IDSTRING(h) = (char *)omAlloc0(len);
     181       case INT_CMD:
     182       case DEF_CMD:
     183       case POLY_CMD:
     184       case VECTOR_CMD:
     185       case QRING_CMD:
     186         break;
     187       default:
     188         {
     189           if (t>MAX_TOK)
     190           {
     191             Print("bb-type %d\n",t);
     192             blackbox *bb=getBlackboxStuff(t);
     193             if (bb!=NULL)
     194               IDSTRING(h)=(char *)bb->blackbox_Init();
     195           }
     196           else
     197             Werror("unknown type %d",t);
     198           break;
     199         }
    185200    }
    186201    // additional settings:--------------------------------------
     
    475490    if (IDDATA(h)!=NULL)
    476491      syKillComputation((syStrategy)IDDATA(h),r);
     492  }
     493  // blackbox -------------------------------------------------------------
     494  else if (IDTYP(h)>MAX_TOK)
     495  {
     496    blackbox *bb=getBlackboxStuff(IDTYP(h));
     497    if (bb!=NULL) bb->blackbox_destroy(bb,IDDATA(h));
     498    IDDATA(h)=NULL;
    477499  }
    478500#ifdef HAVE_FANS
  • Singular/subexpr.cc

    r7bb8434 rb117e8  
    3838#include <Singular/attrib.h>
    3939#include <Singular/subexpr.h>
     40#include <Singular/blackbox.h>
    4041
    4142#ifdef HAVE_FANS
     
    322323          break;
    323324        }
    324 #ifdef TEST
     325
    325326        default:
     327          if (t>MAX_TOK)
     328          {
     329            blackbox * bb=getBlackboxStuff(t);
     330            PrintNSpaces(spaces);
     331            if (bb!=NULL) { bb->blackbox_Print(bb,d); }
     332            else          { ::Print("Print: blackbox %d(bb=NULL)",t); }
     333          }
     334          else
    326335          ::Print("Print:unknown type %s(%d)", Tok2Cmdname(t),t);
    327 #endif
    328336      } /* end switch: (Typ()) */
    329337  }
     
    437445        if (r!=NULL) syKillComputation((syStrategy)data,r);
    438446        break;
    439 #ifdef TEST
    440447      // the following types do not take memory
    441448      // or are not copied
     
    459466        break;
    460467      default:
     468      {
     469        if (rtyp<=MAX_TOK)
    461470        ::Print("CleanUp: unknown type %d\n",rtyp);  /* DEBUG */
    462 #endif
     471        else if (data!=NULL)
     472        {
     473           blackbox *b=getBlackboxStuff(rtyp);
     474           if (b!=NULL) b->blackbox_destroy(b,data);
     475           data=NULL;
     476        }
     477      }
    463478    } /* end switch: (rtyp) */
    464479    //data=NULL; // will be done by Init() at the end
     
    592607    case RESOLUTION_CMD:
    593608      return (void*)syCopy((syStrategy)d);
    594 #ifdef TEST
    595609    case DEF_CMD:
    596610    case NONE:
     
    598612    //case COMMAND:
    599613    default:
     614    {
     615      if (t>MAX_TOK)
     616      {
     617        blackbox *b=getBlackboxStuff(t);
     618        if (b!=NULL) return b->blackbox_Copy(b,d);
     619        return NULL;
     620      }
     621      else
    600622      Warn("s_internalCopy: cannot copy type %s(%d)",
    601623            Tok2Cmdname(t),t);
    602 #endif
     624    }
    603625  }
    604626  return NULL;
     
    933955        case LIST_CMD:
    934956          return lString((lists) d, typed, dim);
     957
     958        default:
     959          if(t> MAX_TOK)
     960          {
     961            blackbox *bb=getBlackboxStuff(t);
     962            if (bb!=NULL) return bb->blackbox_String(bb,d);
     963          }
    935964    } /* end switch: (Typ()) */
    936965  }
  • Singular/tesths.cc

    r7bb8434 rb117e8  
    3232#include <Singular/slInit.h>
    3333#include <Singular/ssiLink.h>
     34#include <Singular/bigintm.h>
    3435
    3536#ifdef HAVE_FACTORY
     
    128129    currPackHdl=h;
    129130    basePackHdl=h;
     131    bigintm_setup();
    130132  }
    131133#endif
Note: See TracChangeset for help on using the changeset viewer.