Out of nowhere I get quite a big result for this function... It should be very simple, but I can't see it now.
double prob_calculator_t::pimpl_t::B_full_term() const
{
double result = 0.0;
for (uint32_t j=0, j_end=U; j<j_end; j++)
{
uint32_t inhabited_columns = doc->row_sums[j];
// DEBUG
cout << "inhabited_columns: " << inhabited_columns << endl;
cout << "log_of_sum[j]: " << log_of_sum[j] << endl;
cout << "sum_of_log[j]: " << sum_of_log[j] << endl;
// end DEBUG
result += ( -inhabited_columns * log( log_of_sum[j] ) + sum_of_log[ j ] );
cout << "result: " << result << endl;
}
return result;
}
and where is the trace:
inhabited_columns: 1
log_of_sum[j]: 110.56
sum_of_log[j]: -2.81341
result: 2.02102e+10
inhabited_columns: 42
log_of_sum[j]: 110.56
sum_of_log[j]: -143.064
result: 4.04204e+10
Thanks for the help!
A telephone number serves as an address for switching telephone calls using a system of destination code routing. Telephone numbers are entered or dialed by a calling party on the originating telephone set, which transmits the sequence of digits in the process of signaling to a telephone exchange.
The curse of 39, also referred to as triakontenneaphobia, is the fear of the number 39. In some parts of Afghanistan, the number is considered to be cursed or a badge of shame as it is purportedly linked with curse, shame, and prostitution.
That's because the number you see is not the caller's actual number. The caller doesn't want people to call back and has forged the number the caller ID shows.
You can call privately by entering *67 before you dial a number, which hides your phone number and name. You can also make a call private by turning off caller ID for all outgoing calls using the settings on your iPhone or Android. By default, everyone you call sees your name and phone number thanks to caller ID.
inhabited_columns
is unsigned and I see a unary -
just before it: -inhabited_columns
.
(Note that unary -
has a really high operator precedence; higher than *
etc).
That is where your problem is! To quote Mike Seymour's answer:
When you negate it, the result is still unsigned; the value is reduced modulo 232 to give a large positive value.
One fix would be to write
-(inhabited_columns * log(log_of_sum[j]))
as then the negation will be carried out in floating point
inhabited_columns
is an unsigned type. When you negate it, the result is still unsigned; the value is reduced modulo 232 to give a large positive value.
You should change it to a sufficiently large signed type (maybe int32_t
, if you're not going to have more than a couple of billion columns), or perhaps double
since you're about to use it in double-precision arithmetic.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With