Package config
Class Settings
Object
Settings
public class Settings
extends Object
The
Settings
class stores global settings as static variables. These settings are read from cas.properties
by parseConfig()
on launch, and can be modified dynamically during runtime.
Settings that are modified during runtime do NOT get written into the properties file. To save a settings profile, write it into cas.properties
so it is read on launch.
The class also contains tools for parsing settings from files and user input, then storing those settings for use by package methods.-
Field Summary
Fields Modifier and Type Field Description static boolean
asteriskMultiplication
Denotes whether or not multiplication should be delimited by asterisks (as in2 * x
) or not (as in2x
)static boolean
cacheDerivatives
Denotes whether or not the derivatives of functions should be cached when created.static FactorialType
defaultFactorial
Denotes the default implementation ofFactorial
to be used.static int
defaultRangeSections
The amount of segments whichSolver
splits a given range into.static double
defaultSleep
The default amount to be slept on newlines inMiscTools.printWithSleep(java.lang.String)
.static int
defaultSolverIterations
The amount of times thatSolver
will run unless the exit conditions are met beforehand.static SolverType
defaultSolverType
Denotes the default method used to solve equations.static boolean
distributeExponents
Denotes whether exponents should be distributed over multiplication insimplify()
.static boolean
distributeFunctions
Denotes whether products are distributed over addition insimplify()
.static boolean
doCombinatorics
Denotes whether or not combinatorial operations should be parsed.static boolean
enforceDomainAndRange
Denotes whether or not inverse simplifications conserve domain and rangestatic boolean
enforceEscapedFunctions
Denotes whether or not expressions likesin(pi/2)
must be escaped to\sin(\pi/2)
.static boolean
enforceEscapedNames
Denotes whether or not the regex for valid variable, function, and constant names should enforce a LaTeX escape in multi-character names.static boolean
enforceIntegerOperations
Forces functions infunctions.unitary.integer
to return integers when using approximations.static boolean
enforcePatternMatchingNames
Denotes whether or not variable, function, and constant names should be checked against the valid name regexParsingTools.validNames
static double
equalsMargin
The default margin to be used when checking if two doubles are equal.static boolean
executeOnSimplify
Denotes whether aTransformation
should execute its action whensimplify()
is called.static boolean
exitSolverOnProximity
Denotes whether methods intools.singlevariable
should exit if the result is within a certain proximity of the target.static double
integerMargin
The margin used inParsingTools.toInteger(double)
when deciding when adouble
is close enough to an integer.static int
maxEscapeLength
The maximum length that a LaTeX escape extends before expiring.static boolean
printStackTraces
Denotes whether full stack traces of errors should be printed for debugging.static boolean
readProperties
When this setting is enabled,Settings
usesparseConfig()
to readcas.properties
and those values are stored in this class.static boolean
removeEscapes
Denotes whether or not escapes should be removed from variable, function, and constant names when printing.static boolean
simplifyFunctionsOfConstants
Denotes whether functions of constants should be simplified.static boolean
simplifyFunctionsOfSpecialConstants
Denotes whether or not special Constants get simplified into decimal under addition, multiplication, or exponentiation.static int
simpsonsSegments
The number of segments thatNumericalIntegration.simpsonsRule(GeneralFunction, double, double)
uses when performing numerical integration.static String
singleVariableDefault
The variable to be used intools.singlevariable
when none is specified.static boolean
truncateNearIntegers
Denotes whether or not constants close to integers are printed as integers (zero not included)static double
zeroMargin
The margin thatSolver
uses to determine if a value is close enough to zero to be considered a root of a function. -
Method Summary
Modifier and Type Method Description static void
parseConfig()
Parses the configuration filecas.properties
and stores the read values inSettings
static void
parseSingleSetting(String key, String value)
Parses string input to a single setting to be stored inSettings
-
Field Details
-
readProperties
public static boolean readPropertiesWhen this setting is enabled,Settings
usesparseConfig()
to readcas.properties
and those values are stored in this class. -
defaultSolverIterations
public static int defaultSolverIterationsThe amount of times thatSolver
will run unless the exit conditions are met beforehand. -
defaultRangeSections
public static int defaultRangeSectionsThe amount of segments whichSolver
splits a given range into. -
simpsonsSegments
public static int simpsonsSegmentsThe number of segments thatNumericalIntegration.simpsonsRule(GeneralFunction, double, double)
uses when performing numerical integration. **MUST BE EVEN** -
maxEscapeLength
public static int maxEscapeLengthThe maximum length that a LaTeX escape extends before expiring. This setting can only be changed through the config; modifying it during runtime will not do anything. -
singleVariableDefault
public static String singleVariableDefaultThe variable to be used intools.singlevariable
when none is specified. -
zeroMargin
public static double zeroMarginThe margin thatSolver
uses to determine if a value is close enough to zero to be considered a root of a function. -
integerMargin
public static double integerMarginThe margin used inParsingTools.toInteger(double)
when deciding when adouble
is close enough to an integer. -
equalsMargin
public static double equalsMarginThe default margin to be used when checking if two doubles are equal. -
defaultSleep
public static double defaultSleepThe default amount to be slept on newlines inMiscTools.printWithSleep(java.lang.String)
. -
enforceEscapedFunctions
public static boolean enforceEscapedFunctionsDenotes whether or not expressions likesin(pi/2)
must be escaped to\sin(\pi/2)
. Enabling this is strongly recommended, and may reduce bugs. -
enforceEscapedNames
public static boolean enforceEscapedNamesDenotes whether or not the regex for valid variable, function, and constant names should enforce a LaTeX escape in multi-character names. Enabling this may improve error handling. -
enforcePatternMatchingNames
public static boolean enforcePatternMatchingNamesDenotes whether or not variable, function, and constant names should be checked against the valid name regexParsingTools.validNames
-
removeEscapes
public static boolean removeEscapesDenotes whether or not escapes should be removed from variable, function, and constant names when printing. -
simplifyFunctionsOfConstants
public static boolean simplifyFunctionsOfConstantsDenotes whether functions of constants should be simplified. Ex:\sin(\pi/2) -> 1
-
simplifyFunctionsOfSpecialConstants
public static boolean simplifyFunctionsOfSpecialConstantsDenotes whether or not special Constants get simplified into decimal under addition, multiplication, or exponentiation. -
distributeExponents
public static boolean distributeExponentsDenotes whether exponents should be distributed over multiplication insimplify()
. Ex:(2x)^2 -> 4x^2
-
cacheDerivatives
public static boolean cacheDerivativesDenotes whether or not the derivatives of functions should be cached when created. -
enforceIntegerOperations
public static boolean enforceIntegerOperationsForces functions infunctions.unitary.integer
to return integers when using approximations. -
exitSolverOnProximity
public static boolean exitSolverOnProximityDenotes whether methods intools.singlevariable
should exit if the result is within a certain proximity of the target. Improves performance at the cost of accuracy. -
executeOnSimplify
public static boolean executeOnSimplifyDenotes whether aTransformation
should execute its action whensimplify()
is called. -
distributeFunctions
public static boolean distributeFunctionsDenotes whether products are distributed over addition insimplify()
. Ex:x(y+z) -> (xy+xz)
-
printStackTraces
public static boolean printStackTracesDenotes whether full stack traces of errors should be printed for debugging. -
enforceDomainAndRange
public static boolean enforceDomainAndRangeDenotes whether or not inverse simplifications conserve domain and range -
asteriskMultiplication
public static boolean asteriskMultiplicationDenotes whether or not multiplication should be delimited by asterisks (as in2 * x
) or not (as in2x
) -
truncateNearIntegers
public static boolean truncateNearIntegersDenotes whether or not constants close to integers are printed as integers (zero not included) -
doCombinatorics
public static boolean doCombinatoricsDenotes whether or not combinatorial operations should be parsed. This setting can only be changed through the config; modifying it during runtime will not do anything. -
defaultSolverType
Denotes the default method used to solve equations. -
defaultFactorial
Denotes the default implementation ofFactorial
to be used.
-
-
Method Details
-
parseConfig
public static void parseConfig() throws IOExceptionParses the configuration filecas.properties
and stores the read values inSettings
- Throws:
IOException
- if the file cannot be found
-
parseSingleSetting
public static void parseSingleSetting(String key, String value)Parses string input to a single setting to be stored inSettings
- Parameters:
key
- the name of the setting, such as defaultSolverIterations or defaultFactorialvalue
- the value of the setting, such as10000
orRECURSIVE
-