Changeset 115639 in git
- Timestamp:
- Mar 1, 2011, 6:21:05 PM (12 years ago)
- Branches:
- (u'jengelh-datetime', 'ceac47cbc86fe4a15902392bdbb9bd2ae0ea02c6')(u'spielwiese', 'a800fe4b3e9d37a38c5a10cc0ae9dfa0c15a4ee6')
- Children:
- b521f3698286cefec0d2866b873155439fcc9619
- Parents:
- 2c470d08ccdc9d28a3c5007e5cc99fe10e6d522c
- Location:
- Singular
- Files:
-
- 4 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/bigintm.cc
r2c470d0 r115639 8 8 #include <Singular/bigintm.h> 9 9 10 // as this is only a demo,11 // we do not included compiled code:12 #if 013 char * bigintm_String(blackbox *b, void *d);14 void * bigintm_Copy(blackbox*b, void *d);15 BOOLEAN bigintm_Assign(leftv l, leftv r);16 BOOLEAN bigintm_Op2(int op, leftv res, leftv a1, leftv a2);17 BOOLEAN bigintm_OpM(int op, leftv res, leftv args);18 void bigintm_destroy(blackbox *b, void *d);19 10 20 void bigintm_setup() 21 { 22 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox)); 23 // all undefined entries will be set to default in setBlackboxStuff 24 // the default Print is quite usefule, 25 // all other are simply error messages 26 b->blackbox_destroy=bigintm_destroy; 27 b->blackbox_String=bigintm_String; 28 //b->blackbox_Print=blackbox_default_Print; 29 //b->blackbox_Init=blackbox_default_Init; 30 b->blackbox_Copy=bigintm_Copy; 31 b->blackbox_Assign=bigintm_Assign; 32 //b->blackbox_Op1=blackboxDefaultOp1; 33 b->blackbox_Op2=bigintm_Op2; 34 //b->blackbox_Op3=blackbox_default_Op3; 35 b->blackbox_OpM=bigintm_OpM; 36 int rt=setBlackboxStuff(b,"bigintm"); 37 Print("create type %d (bigintm)\n",rt); 38 } 11 #define HAVE_BIGINTM 1 39 12 40 char * bigintm_String(blackbox *b, void *d) 13 #ifdef HAVE_BIGINTM 14 static int bigintm_type_id = -1; 15 #endif 16 17 18 #ifdef HAVE_BIGINTM 19 static char * bigintm_String(blackbox *b, void *d) 41 20 { if (d==NULL) return omStrDup("oo"); 42 21 else … … 47 26 } 48 27 } 49 void * bigintm_Copy(blackbox*b, void *d)28 static void * bigintm_Copy(blackbox*b, void *d) 50 29 { number n=(number)d; return nlCopy(n); } 51 30 52 BOOLEAN bigintm_Assign(leftv l, leftv r)31 static BOOLEAN bigintm_Assign(leftv l, leftv r) 53 32 { 33 assume( l->Typ() == bigintm_type_id ); 34 54 35 blackbox *ll=getBlackboxStuff(l->Typ()); 36 55 37 if (r->Typ()>MAX_TOK) 56 38 { 57 blackbox *rr=getBlackboxStuff(r->Typ()); 58 if (l->Typ()==r->Typ()) 39 if (bigintm_type_id == r->Typ()) 59 40 { 41 blackbox *rr=getBlackboxStuff(r->Typ()); 42 60 43 if (l->Data()!=NULL) { number n1=(number)l->Data(); nlDelete(&n1,NULL); } 61 44 number n2=(number)r->CopyD(); … … 72 55 else 73 56 { 74 Werror("assign %d = %d",l->Typ(),r->Typ()); 57 Werror("bigintm_Assign: assign %s (%d) = %s (%d)", 58 getBlackboxName(l->Typ()), l->Typ(), 59 getBlackboxName(r->Typ()), r->Typ()); 75 60 return TRUE; 76 61 } … … 94 79 return TRUE; 95 80 } 96 BOOLEAN bigintm_OpM(int op, leftv res, leftv args);81 static BOOLEAN bigintm_OpM(int op, leftv res, leftv args); 97 82 98 83 99 BOOLEAN bigintm_Op2(int op, leftv res, leftv a1, leftv a2)84 static BOOLEAN bigintm_Op2(int op, leftv res, leftv a1, leftv a2) 100 85 { 101 86 // interpreter: a1 is ist bigintm 87 assume( a1->Typ() == bigintm_type_id ); 88 102 89 blackbox *a=getBlackboxStuff(a1->Typ()); 103 90 number n1=(number)a1->Data(); … … 124 111 return TRUE; 125 112 } 113 default: 114 Werror("bigintm_Op2: op %d not implemented for type %s (%d)", op, getBlackboxName(a1->Typ()), a1->Typ()); 115 break; 126 116 } 127 117 return blackboxDefaultOp2(op,res,a1,a2); 128 118 } 129 119 // BOOLEAN opM(int op, leftv res, leftv args) 130 BOOLEAN bigintm_OpM(int op, leftv res, leftv args)120 static BOOLEAN bigintm_OpM(int op, leftv res, leftv args) 131 121 { 132 122 // interpreter: args->1. arg is ist bigintm 123 assume( args->Typ() == bigintm_type_id ); 133 124 blackbox *a=getBlackboxStuff(args->Typ()); 134 125 switch(op) … … 141 132 } 142 133 default: 143 Werror(" op %d not implemented for type %d",op,args->Typ());134 Werror("bigintm_OpM: op %d not implemented for type %s (%d)", op, getBlackboxName(args->Typ()), args->Typ()); 144 135 break; 145 136 } 146 137 return TRUE; 147 138 } 148 void bigintm_destroy(blackbox *b, void *d)139 static void bigintm_destroy(blackbox *b, void *d) 149 140 { 150 141 if (d!=NULL) … … 154 145 } 155 146 } 147 156 148 #endif 149 150 151 152 153 // this is only a demo 154 BOOLEAN bigintm_setup() 155 { 156 #ifndef HAVE_BIGINTM 157 Werror("bigintm_setup: Sorry BIGINTM was not compiled in!"); 158 return TRUE; // ok, TRUE = error! 159 #else 160 161 if( bigintm_type_id == -1 ) 162 { 163 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox)); 164 // all undefined entries will be set to default in setBlackboxStuff 165 // the default Print is quite usefule, 166 // all other are simply error messages 167 b->blackbox_destroy=bigintm_destroy; 168 b->blackbox_String=bigintm_String; 169 //b->blackbox_Print=blackbox_default_Print; 170 //b->blackbox_Init=blackbox_default_Init; 171 b->blackbox_Copy=bigintm_Copy; 172 b->blackbox_Assign=bigintm_Assign; 173 //b->blackbox_Op1=blackboxDefaultOp1; 174 b->blackbox_Op2=bigintm_Op2; 175 //b->blackbox_Op3=blackbox_default_Op3; 176 b->blackbox_OpM=bigintm_OpM; 177 178 bigintm_type_id = setBlackboxStuff(b,"bigintm"); 179 180 Print("bigintm_setup: create type %d (%s)",bigintm_type_id, getBlackboxName(bigintm_type_id)); 181 PrintLn(); 182 183 return FALSE; // ok, TRUE = error! 184 } else 185 { 186 Werror("bigintm_setup: Sorry should NOT be run twice!"); 187 return TRUE; // ok, TRUE = error! 188 } 189 190 #endif 191 } 192 193 194 -
Singular/bigintm.h
r2c470d0 r115639 2 2 #define BIGINTM_H 3 3 4 voidbigintm_setup();4 BOOLEAN bigintm_setup(); 5 5 6 6 #endif -
Singular/blackbox.cc
r2c470d0 r115639 5 5 #include <Singular/blackbox.h> 6 6 7 //#define BLACKBOX_DEVEL 18 7 #define MAX_BB_TYPES 256 8 // #define BLACKBOX_DEVEL 1 9 9 10 10 static blackbox* blackboxTable[MAX_BB_TYPES]; … … 103 103 blackboxName[where]=omStrDup(n); 104 104 #ifdef BLACKBOX_DEVEL 105 Print("define bb:name=%s:rt=%d (table:cnt=%d)\n",blackboxName[where],where+BLACKBOX_OFFSET,where);105 Print("setBlackboxStuff: define bb:name=%s:rt=%d (table:cnt=%d)\n",blackboxName[where],where+BLACKBOX_OFFSET,where); 106 106 #endif 107 107 if (bb->blackbox_destroy==NULL) bb->blackbox_destroy=blackbox_default_destroy; … … 138 138 { 139 139 #ifdef BLACKBOX_DEVEL 140 Print(" found bb:%s:%d (table:%d)\n",n,i+BLACKBOX_OFFSET,i);140 Print("blackboxIsCmd: found bb:%s:%d (table:%d)\n",n,i+BLACKBOX_OFFSET,i); 141 141 #endif 142 142 tok=i+BLACKBOX_OFFSET; … … 152 152 { 153 153 if (blackboxName[i]!=NULL) 154 Print(" type %d: %s\n",i,blackboxName[i]);154 Print("printBlackboxTypes: blackbox-type %d: %s\n",i,blackboxName[i]); 155 155 } 156 156 } -
Singular/extra.cc
r2c470d0 r115639 162 162 //#endif /* not HAVE_DYNAMIC_LOADING */ 163 163 164 #include <Singular/bigintm.h> 165 164 166 #ifdef ix86_Win 165 167 //#include <Python.h> … … 175 177 #ifdef ix86_Win /* PySingular initialized? */ 176 178 static int PyInitialized = 0; 179 #endif 180 181 #if SIZEOF_LONG == 8 182 static number jjLONG2N(long d) 183 { 184 int i=(int)d; 185 if ((long)i == d) 186 { 187 return nlInit(i, NULL); 188 } 189 else 190 { 191 #if !defined(OM_NDEBUG) && !defined(NDEBUG) 192 omCheckBin(rnumber_bin); 193 #endif 194 number z=(number)omAllocBin(rnumber_bin); 195 #if defined(LDEBUG) 196 z->debug=123456; 197 #endif 198 z->s=3; 199 mpz_init_set_si(z->z,d); 200 return z; 201 } 202 } 203 #else 204 #define jjLONG2N(D) nlInit((int)D, NULL) 177 205 #endif 178 206 … … 3878 3906 printBlackboxTypes(); 3879 3907 return FALSE; 3880 } 3881 else 3908 } else 3909 /*==================== init the bigintm (a sample blackbox) type =========*/ 3910 if(strcmp(sys_cmd,"bigintm_setup") == 0) 3911 { 3912 return bigintm_setup(); 3913 } else 3882 3914 /*==================== Error =================*/ 3883 3915 Werror( "(extended) system(\"%s\",...) %s", sys_cmd, feNotImplemented );
Note: See TracChangeset
for help on using the changeset viewer.