Package tools
Class MiscTools
Object
MiscTools
public class MiscTools
extends Object
The
MiscTools class contains miscellaneous methods.-
Method Summary
Modifier and Type Method Description static longfactorial(int n)Returns n factorial (n!)static intfindClassValue(GeneralFunction function)Returns the location of aGeneralFunctionin its class-based sort order (seeGeneralFunction.sortOrder)static intgcd(int a, int b)Computes the GCD of the inputs.static GeneralFunctionminimalSimplify(GeneralFunction function)Simplifies the input without executing any of the optional simplifications steps enabled and disabled inSettingsstatic voidprintWithSleep(String message)Prints a message, sleeping forSettings.defaultSleepbetween newlines, but not at the endstatic voidprintWithSleep(String message, boolean sleepAtEnd)Prints a message, sleeping forSettings.defaultSleepbetween newlines, then sleeps that same amount at the end ifsleepAtEndis true.static voidprintWithSleep(String message, double time)Prints a message, sleeping fortimeseconds between newlines, but not at the endstatic voidsleep()Sleeps forSettings.defaultSleepsecondsstatic voidsleep(double seconds)Sleeps forsecondssecondsstatic List<Pair<Double,GeneralFunction>>stripConstantsOfSum(Sum sum)Returns a list of the elements in thisSumwith the constants stripped as a pair.static GeneralFunctiontoFirstNonTrivial(GeneralFunction function)ExecutesCommutativeFunction.simplifyTrivialElement()until the function is not aCommutativeFunctionor has a argument count greater than one.
-
Method Details
-
factorial
public static long factorial(int n)Returns n factorial (n!)- Parameters:
n- the number- Returns:
- n!
-
gcd
public static int gcd(int a, int b)Computes the GCD of the inputs. It is preferred to inputa > b, but this is not explicitly necessary.- Parameters:
a- the first inputb- the second input- Returns:
- the GCD of the inputs
-
findClassValue
Returns the location of aGeneralFunctionin its class-based sort order (seeGeneralFunction.sortOrder)- Parameters:
function- the function whose location in the class order is to be found- Returns:
- location in
GeneralFunction.sortOrder
-
stripConstantsOfSum
Returns a list of the elements in thisSumwith the constants stripped as a pair. Ex:x^2+2sin(x)becomes[<1.0, x^2>, <2.0, sin(x)>]- Parameters:
sum- the sum whose constants should be stripped- Returns:
- the list of pairs as specified above
-
toFirstNonTrivial
ExecutesCommutativeFunction.simplifyTrivialElement()until the function is not aCommutativeFunctionor has a argument count greater than one. Ex:(((2*x)))becomes2*x- Parameters:
function- the function to be simplified- Returns:
- the function with all layers removed
-
printWithSleep
public static void printWithSleep(String message)Prints a message, sleeping forSettings.defaultSleepbetween newlines, but not at the end- Parameters:
message- the message to print
-
printWithSleep
public static void printWithSleep(String message, double time)Prints a message, sleeping fortimeseconds between newlines, but not at the end- Parameters:
message- the message to printtime- amount of seconds to sleep
-
printWithSleep
public static void printWithSleep(String message, boolean sleepAtEnd)Prints a message, sleeping forSettings.defaultSleepbetween newlines, then sleeps that same amount at the end ifsleepAtEndis true.- Parameters:
message- the message to printsleepAtEnd- denotes whether the message should end with asleep()
-
sleep
public static void sleep()Sleeps forSettings.defaultSleepseconds -
sleep
public static void sleep(double seconds)Sleeps forsecondsseconds- Parameters:
seconds- the amount of seconds to sleep for
-
minimalSimplify
Simplifies the input without executing any of the optional simplifications steps enabled and disabled inSettings- Parameters:
function- the function to be minimally simplified- Returns:
- the minimally simplified version of the function
-