CPP Entropy class semi-converted to C (does compile)