Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added Config#MAX_POLYNOMIAL_DEGREE_LAGUERRE_SOLVER option #990

Merged
merged 1 commit into from
May 23, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -148,6 +148,9 @@ public class Config {
/** Maximum degree of a polynomial generating function */
public static int MAX_POLYNOMIAL_DEGREE = Integer.MAX_VALUE;

/** Maximum degree of a polynomial for Laguerre solver */
public static int MAX_POLYNOMIAL_DEGREE_LAGUERRE_SOLVER = Integer.MAX_VALUE;

/** Maximum number of loop runs in some Symja functions */
public static long MAX_LOOP_COUNT = Long.MAX_VALUE;

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@
import org.matheclipse.core.eval.EvalAttributes;
import org.matheclipse.core.eval.EvalEngine;
import org.matheclipse.core.eval.exception.JASConversionException;
import org.matheclipse.core.eval.exception.PolynomialDegreeLimitExceeded;
import org.matheclipse.core.eval.exception.Validate;
import org.matheclipse.core.eval.interfaces.AbstractFunctionEvaluator;
import org.matheclipse.core.expression.F;
Expand Down Expand Up @@ -1011,6 +1012,12 @@ public static IAST rootsOfVariable(final IExpr expr, final IExpr denominator,
*/
private static org.hipparchus.complex.Complex[] allComplexRootsLaguerre(
@Nonnull double[] coefficients) {

if (coefficients.length > Config.MAX_POLYNOMIAL_DEGREE_LAGUERRE_SOLVER) {
// PolynomialDegreeLimitExceeded.throwIt(coefficients.length);
return null;
}

for (int j = 0; j < coefficients.length; j++) {
if (!Double.isFinite(coefficients[j])) {
return null;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -255,6 +255,7 @@ public void setUp() {
Config.MAX_MATRIX_DIMENSION_SIZE = 100;
Config.MAX_BIT_LENGTH = 200000;
Config.MAX_POLYNOMIAL_DEGREE = 150;
Config.MAX_POLYNOMIAL_DEGREE_LAGUERRE_SOLVER = 500;
Config.FILESYSTEM_ENABLED = false;
Config.ROUNDING_MODE = RoundingMode.HALF_EVEN;
// fScriptEngine = fScriptManager.getEngineByExtension("m");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2087,6 +2087,13 @@ public void testIssue947() {
"{{x->(1250000*Log(2))/Log(500)}}");
}

@Test
public void testSolveBigExponent() {
// message: Exponent ist out of bounds for function Factor.
check("Solve(40==5000000/E^(x/(2*1/10^6)),x)", //
"{{x->ConditionalExpression(I*1/250000*Pi*C(1)+Log(125000)/500000,C(1)∈Integers)}}");
}

/** The JUnit setup method */
@Override
public void setUp() {
Expand Down
Loading