Package mathvoyage.algebra
Class Algebra
java.lang.Object
mathvoyage.algebra.Algebra
voyager.Algebra.java
- Author:
- Adib Sakhawat
-
Method Summary
Modifier and TypeMethodDescriptiondoubleabs(double number) returns the absolute value of a number.intabs(int number) returns the absolute value of a number.<T extends Number>
doublecubeRoot(T number) Calculates the cube root of a number.doublefloor(double value) Calculates the floor value of a number.intgcd(int a, int b) Calculates the GCD of a number.static AlgebraReturns the singleton instance of this class.intlcm(int a, int b) Calculates LCM of a number.<T extends Comparable<T>>
Tmax(T[] array) Returns the maximum of an array of comparable objects.<T extends Comparable<T>>
Tmax(T a, T b) Returns the maximum of two comparable objects.<T extends Comparable<T>>
intmaxIndex(T[] array) returns the index of the maximum of an array of comparable objects.<T extends Comparable<T>>
Tmin(T[] array) Returns the minimum of an array of comparable objects.<T extends Comparable<T>>
Tmin(T a, T b) Returns the minimum of two comparable objects.<T extends Comparable<T>>
intminIndex(T[] array) returns the index of the minimum of an array of comparable objects.<T extends Number>
doublenthRoot(T x, int n) Finds the nth root of a number.<T extends Number>
doublepow(T base, int exponent) Calculates the power of a number.<T extends Number>
doublesqrt(T number) Calculates the square root of a number.
-
Method Details
-
getInstance
Returns the singleton instance of this class.- Returns:
- The singleton instance
-
abs
public double abs(double number) returns the absolute value of a number.- Parameters:
number- The number- Returns:
- The absolute value
-
abs
public int abs(int number) returns the absolute value of a number.- Parameters:
number- The number- Returns:
- The absolute value
-
min
Returns the minimum of two comparable objects.- Type Parameters:
T- the type parameter- Parameters:
a- The first objectb- The second object- Returns:
- The minimum of the two objects
-
min
Returns the minimum of an array of comparable objects.- Type Parameters:
T- the type parameter- Parameters:
array- The array of objects- Returns:
- The minimum of the array
-
max
Returns the maximum of two comparable objects.- Type Parameters:
T- the type parameter- Parameters:
a- The first objectb- The second object- Returns:
- The maximum of the two objects
-
max
Returns the maximum of an array of comparable objects.- Type Parameters:
T- the type parameter- Parameters:
array- The array of objects- Returns:
- The maximum of the array
-
minIndex
returns the index of the minimum of an array of comparable objects.- Type Parameters:
T- the type parameter- Parameters:
array- The array of objects- Returns:
- The index of the minimum of the array
-
maxIndex
returns the index of the maximum of an array of comparable objects.- Type Parameters:
T- the type parameter- Parameters:
array- The array of objects- Returns:
- The index of the maximum of the array
-
pow
Calculates the power of a number.- Type Parameters:
T- the type parameter- Parameters:
base- The baseexponent- The exponent- Returns:
- The result
-
sqrt
Calculates the square root of a number.- Type Parameters:
T- the type parameter- Parameters:
number- The number- Returns:
- The result
-
cubeRoot
Calculates the cube root of a number.- Type Parameters:
T- the type parameter- Parameters:
number- The number- Returns:
- The result
-
nthRoot
Finds the nth root of a number.- Type Parameters:
T- the type parameter- Parameters:
x- the number which I have to find nth rootn- the root- Returns:
- result double
-
gcd
public int gcd(int a, int b) Calculates the GCD of a number.- Parameters:
a- The first numberb- The second number- Returns:
- The result
-
lcm
public int lcm(int a, int b) Calculates LCM of a number.- Parameters:
a- the ab- the b- Returns:
- The result
-
floor
public double floor(double value) Calculates the floor value of a number.- Parameters:
value- the value- Returns:
- double
-