Example #1
0
/* Update the P to newP and they have the same cube sequence */
void
Update_Partition(pcover newP, pcover P, pset x, pset q, int pos_q)
{
	register pset r, tt=set_save(x), tmp=new_cube();
	register int i, first_pos;
	
	/* The merge cube */
	set_insert(tt, pos_q);
	
	/* Let the first variable of the merge cube is positive */
	first_pos = Get_Var_Pos(tt, 0);
	if ((first_pos % 2) == 0)
		sf_addset(newP, set_save(tt));
	else
		sf_addset(newP, Var_Phase_Inv(tt));
	free_cube(tt);
	
	
	/* Add the other inputs sequently */
	foreachi_set(P, i, r){
		if (set_andp(tmp, r, x)) continue;
		if (set_andp(tmp, r, q)) continue;
		
		sf_addset(newP, r);
	}
	
	free_cube(tmp);
}
Example #2
0
static bool
primes_consensus_special_cases(pset *T, pset_family *Tnew)
  /* will be disposed if answer is determined */
  /* returned only if answer determined */
{
  register pcube *T1, p, ceil, cof=T[0];
  pcube last;
  pcover A;

  /* Check for no cubes in the cover */
  if (T[2] == NULL) {
    *Tnew = new_cover(0);
    free_cubelist(T);
    return TRUE;
  }

  /* Check for only a single cube in the cover */
  if (T[3] == NULL) {
    *Tnew = sf_addset(new_cover(1), set_or(cof, cof, T[2]));
    free_cubelist(T);
    return TRUE;
  }

  /* Check for a row of all 1's (implies function is a tautology) */
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    if (full_row(p, cof)) {
      *Tnew = sf_addset(new_cover(1), cube.fullset);
      free_cubelist(T);
      return TRUE;
    }
  }

  /* Check for a column of all 0's which can be factored out */
  ceil = set_save(cof);
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    INLINEset_or(ceil, ceil, p);
  }
  if (! setp_equal(ceil, cube.fullset)) {
    p = new_cube();
    (void) set_diff(p, cube.fullset, ceil);
    (void) set_or(cof, cof, p);
    free_cube(p);

    A = primes_consensus(T);
    foreach_set(A, last, p) {
      INLINEset_and(p, p, ceil);
    }
Example #3
0
/* Get the first group from P and add the remaining groups to M */
pset
Get_First_Group(pcover P, pcover *M)
{
	register pset result, q;
	register int i;
	
	result = set_save(GETSET(P, 0));
	
	foreachi_set(P, i, q){
		/* The be merged cube */
		if (i == 0) continue;
		
		sf_addset(*M, q);
	}
	
	return result;
}
Example #4
0
static bool compl_special_cases(pset *T, pset_family *Tbar)
  /* will be disposed if answer is determined */
  /* returned only if answer determined */
{
  register pcube *T1, p, ceil, cof=T[0];
  pcover A, ceil_compl;

  /* Check for no cubes in the cover */
  if (T[2] == NULL) {
    *Tbar = sf_addset(new_cover(1), cube.fullset);
    free_cubelist(T);
    return TRUE;
  }

  /* Check for only a single cube in the cover */
  if (T[3] == NULL) {
    *Tbar = compl_cube(set_or(cof, cof, T[2]));
    free_cubelist(T);
    return TRUE;
  }

  /* Check for a row of all 1's (implies complement is null) */
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    if (full_row(p, cof)) {
      *Tbar = new_cover(0);
      free_cubelist(T);
      return TRUE;
    }
  }

  /* Check for a column of all 0's which can be factored out */
  ceil = set_save(cof);
  for(T1 = T+2; (p = *T1++) != NULL; ) {
    INLINEset_or(ceil, ceil, p);
  }
  if (! setp_equal(ceil, cube.fullset)) {
    ceil_compl = compl_cube(ceil);
    (void) set_or(cof, cof, set_diff(ceil, cube.fullset, ceil));
    set_free(ceil);
    *Tbar = sf_append(complement(T), ceil_compl);
    return TRUE;
  }
  set_free(ceil);

  /* Collect column counts, determine unate variables, etc. */
  massive_count(T);

  /* If single active variable not factored out above, then tautology ! */
  if (cdata.vars_active == 1) {
    *Tbar = new_cover(0);
    free_cubelist(T);
    return TRUE;

    /* Check for unate cover */
  } else if (cdata.vars_unate == cdata.vars_active) {
    A = map_cover_to_unate(T);
    free_cubelist(T);
    A = unate_compl(A);
    *Tbar = map_unate_to_cover(A);
    sf_free(A);
    return TRUE;

    /* Not much we can do about it */
  } else {
    return MAYBE;
  }
}
Example #5
0
File: compl.c Project: GtTmy/pyeda
static bool
compl_special_cases(set **T, set_family_t **Tbar)
{
    set **T1, *p, *ceil, *cof=T[0];
    set_family_t *A, *ceil_compl;

    // Check for no cubes in the cover
    if (T[2] == NULL) {
        *Tbar = sf_addset(sf_new(1, CUBE.size), CUBE.fullset);
        free_cubelist(T);
        return TRUE;
    }

    // Check for only a single cube in the cover
    if (T[3] == NULL) {
        *Tbar = compl_cube(set_or(cof, cof, T[2]));
        free_cubelist(T);
        return TRUE;
    }

    // Check for a row of all 1's (implies complement is null)
    for (T1 = T+2; (p = *T1++) != NULL; ) {
        if (full_row(p, cof)) {
            *Tbar = sf_new(0, CUBE.size);
            free_cubelist(T);
            return TRUE;
        }
    }

    // Check for a column of all 0's which can be factored out
    ceil = set_save(cof);
    for (T1 = T+2; (p = *T1++) != NULL; ) {
        set_or(ceil, ceil, p);
    }
    if (! setp_equal(ceil, CUBE.fullset)) {
        ceil_compl = compl_cube(ceil);
        set_or(cof, cof, set_diff(ceil, CUBE.fullset, ceil));
        set_free(ceil);
        *Tbar = sf_append(complement(T), ceil_compl);
        return TRUE;
    }
    set_free(ceil);

    // Collect column counts, determine unate variables, etc.
    massive_count(T);

    // If single active variable not factored out above, then tautology!
    if (CDATA.vars_active == 1) {
        *Tbar = sf_new(0, CUBE.size);
        free_cubelist(T);
        return TRUE;

    // Check for unate cover
    } else if (CDATA.vars_unate == CDATA.vars_active) {
        A = map_cover_to_unate(T);
        free_cubelist(T);
        A = unate_compl(A);
        *Tbar = map_unate_to_cover(A);
        sf_free(A);
        return TRUE;

    // Not much we can do about it
    } else {
        return MAYBE;
    }
}