Package mathvoyage

Class vmath.algebra

java.lang.Object
mathvoyage.vmath.algebra
Enclosing class:
vmath

public static class vmath.algebra extends Object
Contains Basic Algebraic functions to find min, max, min and max index of an array, factorial, and more.
Author:
Adib Sakhawat
  • Constructor Summary

    Constructors
    Constructor
    Description
     
  • Method Summary

    Modifier and Type
    Method
    Description
    static double
    abs(double number)
    Returns the Absolute value of a number.
    static int
    abs(int number)
    Returns the Absolute value of a number.
    static <T extends Comparable<T>>
    int
    argMax(T[] array)
    Returns the index of the maximum of an array of comparable objects.
    static <T extends Comparable<T>>
    int
    argMin(T[] array)
    Returns the index of the minimum of an array of comparable objects.
    static <T extends Number>
    double
    cubeRoot(T number)
    Calculates the cube root of a number.
    static double
    factorial(int number)
    Returns the factorial of a number.
    static double
    floor(double number)
    Returns the floor of a number.
    static int
    gcd(int a, int b)
    Returns the greatest common divisor of two numbers.
    static int
    lcm(int a, int b)
    Returns the least common multiple of two numbers.
    static <T extends Comparable<T>>
    T
    max(T[] array)
    Returns the maximum of an array of comparable objects.
    static <T extends Comparable<T>>
    T
    max(T a, T b)
    Returns the maximum of two comparable objects.
    static <T extends Comparable<T>>
    T
    min(T[] array)
    Returns the minimum of an array of comparable objects.
    static <T extends Comparable<T>>
    T
    min(T a, T b)
    Returns the minimum of two comparable objects.
    static <T extends Number>
    double
    nthRoot(T number, int n)
    Finds the nth root of a number.
    static <T extends Number>
    double
    pow(T base, int exponent)
    Calculates the power of a number.
    static <T extends Number>
    double
    sqrt(T number)
    Calculates the square root of a number.

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • 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

      public static <T extends Comparable<T>> T min(T a, T b)
      Returns the minimum of two comparable objects.
      Type Parameters:
      T - the type parameter
      Parameters:
      a - The first object
      b - The second object
      Returns:
      The minimum of the two objects
    • min

      public static <T extends Comparable<T>> T min(T[] array)
      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

      public static <T extends Comparable<T>> T max(T a, T b)
      Returns the maximum of two comparable objects.
      Type Parameters:
      T - the type parameter
      Parameters:
      a - The first object
      b - The second object
      Returns:
      The maximum of the two objects
    • max

      public static <T extends Comparable<T>> T max(T[] array)
      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

      public static <T extends Comparable<T>> int argMax(T[] array)
      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

      public static <T extends Comparable<T>> int argMin(T[] array)
      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

      public static <T extends Number> double pow(T base, int exponent)
      Calculates the power of a number.
      Type Parameters:
      T - the type parameter
      Parameters:
      base - The base
      exponent - The exponent
      Returns:
      The result
    • sqrt

      public static <T extends Number> double sqrt(T number)
      Calculates the square root of a number.
      Type Parameters:
      T - the type parameter
      Parameters:
      number - The number
      Returns:
      The result
    • cubeRoot

      public static <T extends Number> double cubeRoot(T number)
      Calculates the cube root of a number.
      Type Parameters:
      T - the type parameter
      Parameters:
      number - The number
      Returns:
      The result
    • nthRoot

      public static <T extends Number> double nthRoot(T number, int n)
      Finds the nth root of a number.
      Type Parameters:
      T - the type parameter
      Parameters:
      number - the number which I have to find nth root
      n - 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 a
      b - 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 a
      b - the b
      Returns:
      The least common multiple