Package mathvoyage
Class vmath.algebra
java.lang.Object
mathvoyage.vmath.algebra
- Enclosing class:
vmath
Contains Basic Algebraic functions to find min, max, min and max index of an array, factorial, and more.
- Author:
- Adib Sakhawat
-
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionstatic doubleabs(double number) Returns the Absolute value of a number.static intabs(int number) Returns the Absolute value of a number.static <T extends Comparable<T>>
intargMax(T[] array) Returns the index of the maximum of an array of comparable objects.static <T extends Comparable<T>>
intargMin(T[] array) Returns the index of the minimum of an array of comparable objects.static <T extends Number>
doublecubeRoot(T number) Calculates the cube root of a number.static doublefactorial(int number) Returns the factorial of a number.static doublefloor(double number) Returns the floor of a number.static intgcd(int a, int b) Returns the greatest common divisor of two numbers.static intlcm(int a, int b) Returns the least common multiple of two numbers.static <T extends Comparable<T>>
Tmax(T[] array) Returns the maximum of an array of comparable objects.static <T extends Comparable<T>>
Tmax(T a, T b) Returns the maximum of two comparable objects.static <T extends Comparable<T>>
Tmin(T[] array) Returns the minimum of an array of comparable objects.static <T extends Comparable<T>>
Tmin(T a, T b) Returns the minimum of two comparable objects.static <T extends Number>
doublenthRoot(T number, int n) Finds the nth root of a number.static <T extends Number>
doublepow(T base, int exponent) Calculates the power of a number.static <T extends Number>
doublesqrt(T number) Calculates the square root of a number.
-
Constructor Details
-
algebra
public algebra()
-
-
Method Details
-
floor
public static double floor(double number) Returns the floor of a number.- Parameters:
number- The number- Returns:
- The floor
-
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
-
argMax
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
-
argMin
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
-
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:
number- the number which I have to find nth rootn- the root- Returns:
- result double
-
abs
public static int abs(int number) Returns the Absolute value of a number.- Parameters:
number- The number- Returns:
- The result
-
abs
public static double abs(double number) Returns the Absolute value of a number.- Parameters:
number- The number- Returns:
- The result
-
factorial
public static double factorial(int number) Returns the factorial of a number.- Parameters:
number- The number- Returns:
- The factorial
-
gcd
public static int gcd(int a, int b) Returns the greatest common divisor of two numbers.- Parameters:
a- the ab- the b- Returns:
- The greatest common divisor
-
lcm
public static int lcm(int a, int b) Returns the least common multiple of two numbers.- Parameters:
a- the ab- the b- Returns:
- The least common multiple
-