function p = BR_cc2clauseprob(clause,cc_probs)
% BR_cc2clauseprob - compute clause probability from cc probs
% On input:
%     clause (1xk vector): disjunctive clause
%     cc_probs (1x2^n vector): cc probabilities
% On output:
%     p (float): probability of clause
% Author:
%     T. Henderson
%     UU
%     Fall 2017
%

p = 0;

len_clause = length(clause);
clause_sign = zeros(1,len_clause);
for d = 1:len_clause
    clause_sign(d) = clause(d)>0;
end
num_cc = length(cc_probs);
n = log2(num_cc);
indexes = sort(abs(clause));

for b = 0:num_cc-1
    bits = BR_int2bits(b,n);
    cc_sign = bits(indexes);
    if max(cc_sign==clause_sign)==1
        p = p + cc_probs(b+1);
    end
end
