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 long
factorial(int n)
Returns n factorial (n!)static int
findClassValue(GeneralFunction function)
Returns the location of aGeneralFunction
in its class-based sort order (seeGeneralFunction.sortOrder
)static int
gcd(int a, int b)
Computes the GCD of the inputs.static GeneralFunction
minimalSimplify(GeneralFunction function)
Simplifies the input without executing any of the optional simplifications steps enabled and disabled inSettings
static void
printWithSleep(String message)
Prints a message, sleeping forSettings.defaultSleep
between newlines, but not at the endstatic void
printWithSleep(String message, boolean sleepAtEnd)
Prints a message, sleeping forSettings.defaultSleep
between newlines, then sleeps that same amount at the end ifsleepAtEnd
is true.static void
printWithSleep(String message, double time)
Prints a message, sleeping fortime
seconds between newlines, but not at the endstatic void
sleep()
Sleeps forSettings.defaultSleep
secondsstatic void
sleep(double seconds)
Sleeps forseconds
secondsstatic List<Pair<Double,GeneralFunction>>
stripConstantsOfSum(Sum sum)
Returns a list of the elements in thisSum
with the constants stripped as a pair.static GeneralFunction
toFirstNonTrivial(GeneralFunction function)
ExecutesCommutativeFunction.simplifyTrivialElement()
until the function is not aCommutativeFunction
or 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 aGeneralFunction
in 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 thisSum
with 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 aCommutativeFunction
or 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.defaultSleep
between 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 fortime
seconds 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.defaultSleep
between newlines, then sleeps that same amount at the end ifsleepAtEnd
is true.- Parameters:
message
- the message to printsleepAtEnd
- denotes whether the message should end with asleep()
-
sleep
public static void sleep()Sleeps forSettings.defaultSleep
seconds -
sleep
public static void sleep(double seconds)Sleeps forseconds
seconds- 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
-