function pot = scale_cgpot(pot, scale)
% SCALE_CGPOT Scale a Conditional Gaussian potential to prevent underflow.
% pot = scale_cgpot(pot, scale)

switch pot.subtype
  case 'm'
    for i=1:pot.dsize
      pot.pot{i}.logp = pot.pot{i}.logp + log(scale);
    end
  case 'c'
    for i=1:pot.dsize
      pot.pot{i}.g = pot.pot{i}.g + log(scale);
    end
end
    
