Changeset bca6c6 in git
- Timestamp:
- Mar 2, 2011, 9:45:23 AM (13 years ago)
- Branches:
- (u'fieker-DuVal', '117eb8c30fc9e991c4decca4832b1d19036c4c65')(u'spielwiese', 'b4f17ed1d25f93d46dbe29e4b499baecc2fd51bb')
- Children:
- 31a04de9654ef6c91a67d31ba39e3e2f1c9537fe
- Parents:
- b521f3698286cefec0d2866b873155439fcc9619
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
Singular/bigintm.cc
rb521f3 rbca6c6 1 // as this file provides only example code, 2 // no trace of it must appear in Singular and Singularg 3 // 4 #if 0 5 // 1 6 #include <Singular/mod2.h> 2 7 #include <Singular/ipid.h> … … 9 14 10 15 11 #define HAVE_BIGINTM 112 13 #ifdef HAVE_BIGINTM14 static int bigintm_type_id = -1;15 #endif16 17 18 #ifdef HAVE_BIGINTM19 16 static char * bigintm_String(blackbox *b, void *d) 20 17 { if (d==NULL) return omStrDup("oo"); … … 31 28 static BOOLEAN bigintm_Assign(leftv l, leftv r) 32 29 { 33 assume( l->Typ() == bigintm_type_id );34 35 30 blackbox *ll=getBlackboxStuff(l->Typ()); 36 31 37 32 if (r->Typ()>MAX_TOK) 38 33 { 39 if ( bigintm_type_id== r->Typ())34 if (l->Typ() == r->Typ()) 40 35 { 41 36 blackbox *rr=getBlackboxStuff(r->Typ()); … … 85 80 { 86 81 // interpreter: a1 is ist bigintm 87 assume( a1->Typ() == bigintm_type_id );88 82 89 83 blackbox *a=getBlackboxStuff(a1->Typ()); … … 112 106 } 113 107 default: 114 Werror("bigintm_Op2: op %d not implemented for type %s (%d)", op, getBlackboxName(a1->Typ()), a1->Typ()); 115 break; 108 return blackboxDefaultOp2(op,res,a1,a2); 116 109 } 117 110 return blackboxDefaultOp2(op,res,a1,a2); … … 121 114 { 122 115 // interpreter: args->1. arg is ist bigintm 123 assume( args->Typ() == bigintm_type_id );124 116 blackbox *a=getBlackboxStuff(args->Typ()); 125 117 switch(op) … … 132 124 } 133 125 default: 134 Werror("bigintm_OpM: op %d not implemented for type %s (%d)", op, getBlackboxName(args->Typ()), args->Typ());126 return blackboxDefaultOpM(op,res,args); 135 127 break; 136 128 } 137 return TRUE;129 return blackboxDefaultOpM(op,res,args); 138 130 } 139 131 static void bigintm_destroy(blackbox *b, void *d) … … 146 138 } 147 139 148 #endif149 140 150 151 152 153 // this is only a demo154 141 BOOLEAN bigintm_setup() 155 142 { 156 #ifndef HAVE_BIGINTM 157 Werror("bigintm_setup: Sorry BIGINTM was not compiled in!"); 158 return TRUE; // ok, TRUE = error! 159 #else 143 // it is not very usefull to call this setup routine twice, 144 // but (as this is an example) it is possible. 145 // Other blackbox type really require multiple setup calls 146 // (with different names). 147 // Also the format of this setup routine is not fixed, 148 // it may take additional parameters, it may return a value or not 149 // - it really depends. 160 150 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; 151 blackbox *b=(blackbox*)omAlloc0(sizeof(blackbox)); 152 // all undefined entries will be set to default in setBlackboxStuff 153 // the default Print is quite usefule, 154 // all other are simply error messages 155 b->blackbox_destroy=bigintm_destroy; 156 b->blackbox_String=bigintm_String; 157 //b->blackbox_Print=blackbox_default_Print; 158 //b->blackbox_Init=blackbox_default_Init; 159 b->blackbox_Copy=bigintm_Copy; 160 b->blackbox_Assign=bigintm_Assign; 161 //b->blackbox_Op1=blackboxDefaultOp1; 162 b->blackbox_Op2=bigintm_Op2; 163 //b->blackbox_Op3=blackbox_default_Op3; 164 b->blackbox_OpM=bigintm_OpM; 165 int rt=setBlackboxStuff(b,"bigintm"); 177 166 178 bigintm_type_id = setBlackboxStuff(b,"bigintm");167 Print("bigintm_setup: create type %d (%s)\n",rt, getBlackboxName(rt)); 179 168 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 } 169 return FALSE; // ok, TRUE = error!: this example never fails 170 } 189 171 190 172 #endif 191 }192 193 194
Note: See TracChangeset
for help on using the changeset viewer.