1
0
mirror of https://github.com/DanilaFe/abacus synced 2024-12-22 07:20:09 -08:00

Modify exp to work properly with the new changes and support all reals.

This commit is contained in:
Arthur Drobot 2017-07-27 10:16:38 -07:00
parent 7a0fa31cad
commit 3e52a9d645

View File

@ -4,6 +4,7 @@ import org.nwapw.abacus.function.Function;
import org.nwapw.abacus.number.NaiveNumber;
import org.nwapw.abacus.number.NumberInterface;
import javax.print.attribute.standard.MediaSize;
import java.util.function.BiFunction;
/**
@ -116,7 +117,13 @@ public class StandardPlugin extends Plugin {
@Override
protected NumberInterface applyInternal(NumberInterface[] params) {
return sumSeries(params[0], StandardPlugin.this::getExpSeriesTerm, getNTermsExp(getMaxError(params[0]), params[0]));
boolean takeReciprocal = params[0].signum() == -1;
params[0] = StandardPlugin.this.getFunction("abs").apply(params[0]);
NumberInterface sum = sumSeries(params[0], StandardPlugin.this::getExpSeriesTerm, getNTermsExp(getMaxError(params[0]), params[0]));
if(takeReciprocal){
sum = NaiveNumber.ONE.promoteTo(sum.getClass()).divide(sum);
}
return sum;
}
});
}