MCPcopy Create free account
hub / github.com/Singular/Singular / drop_last_weighted_variable

Method drop_last_weighted_variable

IntegerProgramming/binomial.cc:1449–1527  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1447
1448
1449BOOLEAN binomial::drop_last_weighted_variable(const term_ordering& w)
1450{
1451 _number_of_variables--;
1452 // dangerous!!
1453
1454 // copy components of interest to save memory
1455 // the leading term has to be recomputed!!
1456
1457 Integer *aux=exponent_vector;
1458 exponent_vector=new Integer[_number_of_variables];
1459
1460 short last_weighted_variable=w.number_of_weighted_variables()-1;
1461 aux[last_weighted_variable]=0;
1462 // set last component to zero, so it cannot influence the weight
1463
1464 if(w.weight(aux)>=0)
1465 {
1466 for(short i=0;i<last_weighted_variable;i++)
1467 exponent_vector[i]=aux[i];
1468 for(short i=last_weighted_variable;i<_number_of_variables;i++)
1469 exponent_vector[i]=aux[i+1];
1470 }
1471 else
1472 {
1473 for(short i=0;i<last_weighted_variable;i++)
1474 exponent_vector[i]=-aux[i];
1475 for(short i=last_weighted_variable;i<_number_of_variables;i++)
1476 exponent_vector[i]=-aux[i+1];
1477 }
1478
1479 delete[] aux;
1480
1481
1482#ifdef SUPPORT_DRIVEN_METHODS
1483
1484 // Recompute head and tail.
1485 // Normally, this routine is only called for binomials that do not involve
1486 // the variable to be dropped. But if SUPPORT_VARIABLES_LAST is enabled,
1487 // the support changes in spite of this. Therefore, the support is
1488 // recomputed... For the same reasons as mentioned in the preceding
1489 // routines, the existing support information is not used.
1490
1491 head_support=0;
1492 tail_support=0;
1493 short size_of_support_vectors=CHAR_BIT*sizeof(unsigned long);
1494 if(size_of_support_vectors>_number_of_variables)
1495 size_of_support_vectors=_number_of_variables;
1496
1497
1498#ifdef SUPPORT_VARIABLES_FIRST
1499
1500 for(short i=0;i<size_of_support_vectors;i++)
1501 {
1502 Integer actual_entry=exponent_vector[i];
1503 if(actual_entry>0)
1504 head_support|=(1<<i);
1505 else if(actual_entry<0)
1506 tail_support|=(1<<i);

Callers 1

ideal_stuff.ccFile · 0.80

Calls 2

weightMethod · 0.45

Tested by

no test coverage detected