Skip to content
This repository was archived by the owner on May 11, 2021. It is now read-only.

Commit d700322

Browse files
committed
reverted rp_interval_pow to realpaver implementation because of bug in filib
1 parent 06c719a commit d700322

File tree

1 file changed

+43
-42
lines changed

1 file changed

+43
-42
lines changed

src/realpaver/rp_interval.cpp

Lines changed: 43 additions & 42 deletions
Original file line numberDiff line numberDiff line change
@@ -1106,55 +1106,56 @@ void rp_interval_sqrt(rp_interval result, rp_interval i)
11061106
/* let n=[j,j], result := i^j */
11071107
void rp_interval_pow(rp_interval result, rp_interval i, rp_interval n)
11081108
{
1109+
/*
11091110
interval t(rp_binf(i), rp_bsup(i));
11101111
interval i_n(rp_binf(n), rp_bsup(n));
11111112
t = pow(t, i_n);
11121113
rp_binf(result) = t.inf();
11131114
rp_bsup(result) = t.sup();
11141115
return;
1116+
*/
1117+
int exp = (int)rp_binf(n);
11151118

1116-
// int exp = (int)rp_binf(n);
1117-
1118-
// if( rp_even(exp) ) /* n even */
1119-
// {
1120-
// rp_interval z;
1121-
// rp_interval_abs(z,i);
1122-
// if (rp_binf(z)==0.0)
1123-
// {
1124-
// rp_binf(result) = 0.0;
1125-
// }
1126-
// else
1127-
// {
1128-
// rp_binf(result) = rp_pow(rp_binf(z),exp,RP_ROUND_VALUE_DOWN);
1129-
// }
1130-
// if (rp_bsup(z)==RP_INFINITY)
1131-
// {
1132-
// rp_bsup(result) = RP_INFINITY;
1133-
// }
1134-
// else
1135-
// {
1136-
// rp_bsup(result) = rp_pow(rp_bsup(z),exp,RP_ROUND_VALUE_UP);
1137-
// }
1138-
// }
1139-
// else /* rp_odd(exp) */
1140-
// {
1141-
// if (rp_binf(i)==(-RP_INFINITY))
1142-
// {
1143-
// rp_binf(result) = (-RP_INFINITY);
1144-
// }
1145-
// else
1146-
// {
1147-
// rp_binf(result) = rp_pow(rp_binf(i),exp,RP_ROUND_VALUE_DOWN);
1148-
// }
1149-
// if (rp_bsup(i)==RP_INFINITY)
1150-
// {
1151-
// rp_bsup(result) = RP_INFINITY;
1152-
// }
1153-
// else
1154-
// {
1155-
// rp_bsup(result) = rp_pow(rp_bsup(i),exp,RP_ROUND_VALUE_UP);
1156-
// }
1157-
// }
1119+
if( rp_even(exp) ) /* n even */
1120+
{
1121+
rp_interval z;
1122+
rp_interval_abs(z,i);
1123+
if (rp_binf(z)==0.0)
1124+
{
1125+
rp_binf(result) = 0.0;
1126+
}
1127+
else
1128+
{
1129+
rp_binf(result) = rp_pow(rp_binf(z),exp,RP_ROUND_VALUE_DOWN);
1130+
}
1131+
if (rp_bsup(z)==RP_INFINITY)
1132+
{
1133+
rp_bsup(result) = RP_INFINITY;
1134+
}
1135+
else
1136+
{
1137+
rp_bsup(result) = rp_pow(rp_bsup(z),exp,RP_ROUND_VALUE_UP);
1138+
}
1139+
}
1140+
else /* rp_odd(exp) */
1141+
{
1142+
if (rp_binf(i)==(-RP_INFINITY))
1143+
{
1144+
rp_binf(result) = (-RP_INFINITY);
1145+
}
1146+
else
1147+
{
1148+
rp_binf(result) = rp_pow(rp_binf(i),exp,RP_ROUND_VALUE_DOWN);
1149+
}
1150+
if (rp_bsup(i)==RP_INFINITY)
1151+
{
1152+
rp_bsup(result) = RP_INFINITY;
1153+
}
1154+
else
1155+
{
1156+
rp_bsup(result) = rp_pow(rp_bsup(i),exp,RP_ROUND_VALUE_UP);
1157+
}
1158+
}
11581159
}
11591160

11601161
/* result := exp(i) */

0 commit comments

Comments
 (0)