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

Method compute_flip_variables

IntegerProgramming/matrix.cc:517–577  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

515}
516
517int matrix::compute_flip_variables(int*& F)
518{
519 // first compute nonzero vector
520 int okay=compute_nonzero_kernel_vector();
521
522 if(!okay)
523 {
524 cout<<"\nWARNING: int matrix::compute_flip_variables(int*&):\n"
525 "kernel of the matrix contains no vector with nonzero components,\n"
526 "no flip variables computed"<<endl;
527 return -1;
528 }
529
530 // compute variables to flip; these might either be those corresponding
531 // to the positive components of the kernel vector without zero components
532 // or those corresponding to the negative ones
533
534 int r=0;
535 // number of flip variables
536
537 for(int j=0;j<columns;j++)
538 if(H[0][j]<BigInt(0))
539 r++;
540 // remember that all components of H[0] are !=0
541
542 if(r==0)
543 // no flip variables
544 return 0;
545
546 if(2*r>columns)
547 // more negative than positive components in H[0]
548 // all variables corresponding to positive components will be flipped
549 {
550 r=columns-r;
551 F=new int[r];
552 memset(F,0,r*sizeof(int));
553 int counter=0;
554 for(int j=0;j<columns;j++)
555 if(H[0][j]> BigInt(0))
556 {
557 F[counter]=j;
558 counter++;
559 }
560 }
561 else
562 // more (or as many) positive than negative components in v
563 // all variables corresponding to negative components will be flipped
564 {
565 F=new int[r];
566 memset(F,0,r*sizeof(int));
567 int counter=0;
568 for(int j=0;j<columns;j++)
569 if(H[0][j]< BigInt(0))
570 {
571 F[counter]=j;
572 counter++;
573 }
574 }

Callers 2

DiBiase_UrbankeFunction · 0.80
ideal.ccFile · 0.80

Calls 1

BigIntClass · 0.85

Tested by

no test coverage detected