Changeset bddc9d in git
- Timestamp:
- May 11, 2005, 4:58:35 PM (19 years ago)
- Branches:
- (u'spielwiese', 'fe61d9c35bf7c61f2b6cbf1b56e25e2f08d536cc')
- Children:
- d149eb6e9a07ad85963aa398b2cddef32eedb4de
- Parents:
- 36b1aae16eb13901ec207669cb99003b1937e4c1
- Location:
- kernel
- Files:
-
- 2 edited
Legend:
- Unmodified
- Added
- Removed
-
kernel/tgb.cc
r36b1aa rbddc9d 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: tgb.cc,v 1.1 5 2005-05-11 14:36:01bricken Exp $ */7 /* $Id: tgb.cc,v 1.16 2005-05-11 14:58:34 bricken Exp $ */ 8 8 /* 9 9 * ABSTRACT: slimgb and F4 implementation … … 185 185 else s=bucket_guess(bucket); 186 186 } 187 if (sum!=NULL){ 188 if (c->is_char0) 189 s+=kSBucketLength(sum->ac->bucket); 190 else 191 { 192 if((pLexOrder) &&(!c->is_homog)) 193 //if (false) 194 s+=kEBucketLength(sum->ac->bucket,this->p,c); 195 else 196 s+=bucket_guess(sum->ac->bucket); 197 } 198 } 187 199 188 return s; 200 189 } … … 526 515 void red_object::canonicalize(){ 527 516 kBucketCanonicalize(bucket); 528 if(sum) 529 kBucketCanonicalize(sum->ac->bucket); 517 530 518 531 519 } … … 1677 1665 red_object r2=ro; 1678 1666 ro.validate(); 1679 if ((r2.p!=ro.p)||(r2.sev!=ro.sev) ||(r2.sum!=ro.sum)) return FALSE;1667 if ((r2.p!=ro.p)||(r2.sev!=ro.sev)) return FALSE; 1680 1668 return TRUE; 1681 1669 } … … 1863 1851 buf[j].p=p[j]; 1864 1852 buf[j].sev=pGetShortExpVector(p[j]); 1865 buf[j].sum=NULL;1866 1853 buf[j].bucket = kBucketCreate(currRing); 1867 1854 int len=pLength(p[j]); … … 4156 4143 } 4157 4144 void red_object::flatten(){ 4158 if (sum!=NULL)4159 {4160 4161 4162 if(kBucketGetLm(sum->ac->bucket)!=NULL){4163 number mult_my=n_Mult(sum->c_my,sum->ac->multiplied,currRing);4164 number mult_my_h=mult_my;4165 number ac_h=sum->c_ac;4166 ksCheckCoeff(&mult_my_h, &ac_h);4167 nDelete(&sum->c_ac);4168 nDelete(&mult_my);4169 mult_my=mult_my_h;4170 sum->c_ac=ac_h;4171 poly add_this;4172 if(!nIsOne(mult_my))4173 kBucket_Mult_n(bucket,mult_my);4174 int len;4175 poly clear_into;4176 kBucketClear(sum->ac->bucket,&clear_into,&len);4177 if(sum->ac->counter>1){4178 add_this=pCopy(clear_into);4179 kBucketInit(sum->ac->bucket,clear_into,len);4180 }4181 else4182 add_this=clear_into;4183 if(!nIsOne(sum->c_ac))4184 pMult_nn(add_this, sum->c_ac);4185 4186 kBucket_Add_q(bucket,add_this, &len);4187 nDelete(&mult_my);4188 4189 }4190 nDelete(&sum->c_ac);4191 nDelete(&sum->c_my);4192 4193 sum->ac->decrease_counter();4194 delete sum;4195 p=kBucketGetLm(bucket);4196 sum=NULL;4197 }4198 4145 assume(p==kBucketGetLm(bucket)); 4199 assume(sum==NULL);4200 4146 } 4201 4147 void red_object::validate(){ 4202 BOOLEAN flattened=FALSE; 4203 if(sum!=NULL) 4204 { 4205 poly lm=kBucketGetLm(bucket); 4206 poly lm_ac=kBucketGetLm(sum->ac->bucket); 4207 if ((lm_ac==NULL)||((lm!=NULL) && (pLmCmp(lm,lm_ac)!=-1))){ 4208 flatten(); 4209 assume(sum==NULL); 4210 flattened=TRUE; 4211 p=kBucketGetLm(bucket); 4212 if (p!=NULL) 4213 sev=pGetShortExpVector(p); 4214 } 4215 else 4216 { 4217 4218 p=lm_ac; 4219 assume(sum->ac->sev==pGetShortExpVector(p)); 4220 sev=sum->ac->sev; 4221 } 4222 4223 } 4224 else{ 4225 p=kBucketGetLm(bucket); 4226 if(p) 4148 p=kBucketGetLm(bucket); 4149 if(p) 4227 4150 sev=pGetShortExpVector(p); 4228 }4229 assume((sum==NULL)||(kBucketGetLm(sum->ac->bucket)!=NULL));4230 4151 } 4231 4152 int red_object::clear_to_poly(){ … … 4238 4159 4239 4160 4240 void red_object::adjust_coefs(number c_r, number c_ac_r){ 4241 assume(this->sum!=NULL); 4242 number n1=nMult(sum->c_my, c_ac_r); 4243 number n2=nMult(sum->c_ac,c_r); 4244 nDelete(&sum->c_my); 4245 nDelete(&sum->c_ac); 4246 4247 int ct = ksCheckCoeff(&n1, &n2); 4248 sum->c_my=n1; 4249 sum->c_ac=nNeg(n2); 4250 // nDelete(&n2); 4251 4252 4253 } 4161 4254 4162 4255 4163 void reduction_step::reduce(red_object* r, int l, int u){} … … 4260 4168 } 4261 4169 4262 void simple_reducer::target_is_a_sum_reduce(red_object & ro){ 4263 pTest(p); 4264 kbTest(ro.bucket); 4265 kbTest(ro.sum->ac->bucket); 4266 assume(ro.sum!=NULL); 4267 assume(ro.sum->ac!=NULL); 4268 if(ro.sum->ac->last_reduction_id!=reduction_id){ 4269 number n1=kBucketPolyRed(ro.sum->ac->bucket,p, p_len, c->strat->kNoether); 4270 number n2=nMult(n1,ro.sum->ac->multiplied); 4271 nDelete(&ro.sum->ac->multiplied); 4272 nDelete(&n1); 4273 ro.sum->ac->multiplied=n2; 4274 poly lm=kBucketGetLm(ro.sum->ac->bucket); 4275 if (lm) 4276 ro.sum->ac->sev=pGetShortExpVector(lm); 4277 ro.sum->ac->last_reduction_id=reduction_id; 4278 } 4279 ro.sev=ro.sum->ac->sev; 4280 ro.p=kBucketGetLm(ro.sum->ac->bucket); 4281 } 4170 4282 4171 void simple_reducer::reduce(red_object* r, int l, int u){ 4283 4172 this->pre_reduce(r,l,u); … … 4294 4183 4295 4184 4296 if(r[i].sum==NULL) 4297 this->target_is_no_sum_reduce(r[i]); 4298 4299 else 4300 { 4301 this->target_is_a_sum_reduce(r[i]); 4302 //reduce and adjust multiplied 4303 r[i].sum->ac->last_reduction_id=reduction_id; 4304 4305 } 4306 //most elegant would be multimethods at this point and subclassing 4307 //red_object for sum 4185 4186 this->target_is_no_sum_reduce(r[i]); 4308 4187 4309 4188 } … … 4311 4190 r[i].validate(); 4312 4191 #ifdef TGB_DEBUG 4313 if (r[i].sum) r[i].sev=r[i].sum->ac->sev;4314 4315 4192 #endif 4316 4193 } 4317 4194 } 4318 4195 reduction_step::~reduction_step(){} … … 4386 4263 if(red_len>2*c->average_length){ 4387 4264 for(i=erg.to_reduce_l;i<=erg.to_reduce_u;i++){ 4388 if((r[i].sum==NULL) ||(r[i].sum->ac->counter<=AC_FLATTEN))red_c++;4265 red_c++; 4389 4266 } 4390 4267 } … … 4408 4285 4409 4286 4410 reduction_accumulator::reduction_accumulator(poly p, int p_len, poly high_to){ 4411 //sev needs to be removed from interfaces,makes no sense 4412 4413 4414 poly my=pOne(); 4415 counter=0; 4416 4417 for(int i=1;i<=pVariables;i++) 4418 pSetExp(my,i,(pGetExp(high_to, i)-pGetExp(p,i))); 4419 pSetm(my); 4420 4421 last_reduction_id=-1; 4422 multiplied=nInit(1); 4423 bucket=kBucketCreate(currRing); 4424 poly a=pMult_mm(pCopy(p->next),my); 4425 4426 this->sev=pGetShortExpVector(a); 4427 kBucketInit(bucket, a,p_len-1); 4428 pDelete(&my); 4429 } 4287 4430 4288 void simple_reducer:: pre_reduce(red_object* r, int l, int u){} 4431 4289 -
kernel/tgb_internal.h
r36b1aa rbddc9d 5 5 * Computer Algebra System SINGULAR * 6 6 ****************************************/ 7 /* $Id: tgb_internal.h,v 1. 6 2005-05-11 14:36:02bricken Exp $ */7 /* $Id: tgb_internal.h,v 1.7 2005-05-11 14:58:35 bricken Exp $ */ 8 8 /* 9 9 * ABSTRACT: tgb internal .h file … … 55 55 56 56 //static ideal debug_Ideal; 57 /** 58 reduction_accumulators are objects which are shared by several sums 59 **/ 60 61 class reduction_accumulator{ 62 63 public: 64 /// (1/multiplied)*bucket=reduced original data 65 number multiplied; 66 ///the polynomial data 67 kBucket_pt bucket; 68 /// the short exponent vector 69 unsigned long sev; 70 /// the reference counter 71 int counter; 72 /// decrease the reference counter, at 0 it deletes the object 73 void decrease_counter(){ 74 if((--counter)==0) 75 { 76 delete this; //self destruction 77 } 78 } 79 int last_reduction_id; 80 reduction_accumulator(poly p, int p_len, poly high_to); 81 ~reduction_accumulator(){ 82 nDelete(&multiplied); 83 kBucketDeleteAndDestroy(&bucket); 84 } 85 86 87 }; 57 58 88 59 struct poly_list_node{ 89 60 poly p; 90 61 poly_list_node* next; 91 62 }; 92 struct formal_sum_descriptor{ 93 number c_my; 94 number c_ac; 95 reduction_accumulator* ac; 96 }; 63 97 64 struct int_pair_node{ 98 65 int_pair_node* next; … … 163 130 kBucket_pt bucket; 164 131 poly p; 165 formal_sum_descriptor* sum;166 132 unsigned long sev; 167 133 void flatten(); … … 244 210 ~simple_reducer(); 245 211 246 virtual void target_is_a_sum_reduce(red_object & ro); 212 247 213 virtual void target_is_no_sum_reduce(red_object & ro); 248 214 };
Note: See TracChangeset
for help on using the changeset viewer.