diff --git a/inst/ccubes.cl b/inst/ccubes.cl index ab01bf1..5572ce8 100755 --- a/inst/ccubes.cl +++ b/inst/ccubes.cl @@ -258,25 +258,30 @@ ccubes_task(int k, } // Rprintf("task: %d; rows: %d\n", task, *found); + // this should rarely be more than 5 (because k rarely exceeds 5) + // if it reaches 10 something is way wrong + int bit_index[10]; + + unsigned int fixed[IMPLICANT_WORDS]; + for (int i = 0; i < IMPLICANT_WORDS; i++) { + fixed[i] = 0U; + } + + for (int c = 0; c < k; c++) { + bit_index[c] = (tempk[c] % (BITS_PER_WORD / VALUE_BIT_WIDTH)) * VALUE_BIT_WIDTH; + int word_index = tempk[c] / (BITS_PER_WORD / VALUE_BIT_WIDTH); + fixed_bits[word_index] |= (VALUE_BIT_MASK << bit_index[c]); + } + for (int f = 0; f < *found; f++) { - // create a temporary vector of length k, containing the values from the initial ON set - // plus 1 (because 0 now signals a minimization, it becomes 1, and 1 becomes 2 etc). - int tempc[NINPUTS]; - for (int c = 0; c < k; c++) { - int value = ON_set[tempk[c] * POSROWS + frows[f]]; - tempc[c] = value + 1; - int word_index = tempk[c] / (BITS_PER_WORD / VALUE_BIT_WIDTH); - int bit_index = (tempk[c] % (BITS_PER_WORD / VALUE_BIT_WIDTH)) * VALUE_BIT_WIDTH; - - fixed_bits[f * POSROWS + word_index] |= (VALUE_BIT_MASK << bit_index); - value_bits[f * POSROWS + word_index] |= ((unsigned int)value << bit_index); + fixed_bits[f * POSROWS + word_index] = fixed_bits[word_index]; + value_bits[f * POSROWS + word_index] |= ((unsigned int)ON_set[tempk[c] * POSROWS + frows[f]] << bit_index[c]); } // check if the current PI is not redundant - // bool redundant = false; redundant[f] = false; int i = 0;