Package org.nevec.rjm

Class BigIntegerMath


  • public class BigIntegerMath
    extends java.lang.Object
    BigInteger special functions and Number theory.
    Since:
    2009-08-06
    Author:
    Richard J. Mathar
    • Constructor Summary

      Constructors 
      Constructor Description
      BigIntegerMath()  
    • Method Summary

      All Methods Static Methods Concrete Methods 
      Modifier and Type Method Description
      static java.math.BigInteger binomial​(int n, int k)
      Evaluate binomial(n,k).
      static java.math.BigInteger binomial​(java.math.BigInteger n, java.math.BigInteger k)
      Evaluate binomial(n,k).
      static Rational centrlFactNumt​(int n, int k)
      The central factorial number t(n,k) number at the indices provided.
      static Rational centrlFactNumT​(int n, int k)
      The central factorial number T(n,k) number at the indices provided.
      static java.math.BigInteger core​(java.math.BigInteger n)
      Evaluate core(n).
      static java.math.BigInteger det​(java.math.BigInteger[][] A)
      Determinant of an integer square matrix.
      static java.util.Vector<java.math.BigInteger> divisors​(java.math.BigInteger n)
      Compute the list of positive divisors.
      static int isqrt​(int n)
      Evaluate floor(sqrt(n)).
      static long isqrt​(long n)
      Evaluate floor(sqrt(n)).
      static java.math.BigInteger isqrt​(java.math.BigInteger n)
      Evaluate floor(sqrt(n)).
      static java.math.BigInteger lcm​(java.math.BigInteger a, java.math.BigInteger b)
      The lowest common multiple
      static java.math.BigInteger[][] minor​(java.math.BigInteger[][] A, int r, int c)
      Minor of an integer matrix.
      static java.math.BigInteger sigma​(int n)
      Evaluate sigma(n).
      static java.math.BigInteger sigma​(java.math.BigInteger n)
      Evaluate sigma(n).
      static java.math.BigInteger sigmak​(java.math.BigInteger n, int k)
      Evaluate sigma_k(n).
      static Rational[] solve​(java.math.BigInteger[][] A, java.math.BigInteger[] rhs)
      Solve a linear system of equations.
      static java.math.BigInteger valueOf​(java.util.Vector<java.math.BigInteger> c, java.math.BigInteger x)
      Evaluate the value of an integer polynomial at some integer argument.
      • Methods inherited from class java.lang.Object

        clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
    • Constructor Detail

      • BigIntegerMath

        public BigIntegerMath()
    • Method Detail

      • binomial

        public static java.math.BigInteger binomial​(int n,
                                                    int k)
        Evaluate binomial(n,k).
        Parameters:
        n - The upper index
        k - The lower index
        Returns:
        The binomial coefficient
      • binomial

        public static java.math.BigInteger binomial​(java.math.BigInteger n,
                                                    java.math.BigInteger k)
        Evaluate binomial(n,k).
        Parameters:
        n - The upper index
        k - The lower index
        Returns:
        The binomial coefficient
        Since:
        2008-10-15
      • sigmak

        public static java.math.BigInteger sigmak​(java.math.BigInteger n,
                                                  int k)
        Evaluate sigma_k(n).
        Parameters:
        n - the main argument which defines the divisors
        k - the lower index, which defines the power
        Returns:
        The sum of the k-th powers of the positive divisors
      • sigma

        public static java.math.BigInteger sigma​(int n)
        Evaluate sigma(n).
        Parameters:
        n - the argument for which divisors will be searched.
        Returns:
        the sigma function. Sum of the positive divisors of the argument.
        Since:
        2006-08-14
      • divisors

        public static java.util.Vector<java.math.BigInteger> divisors​(java.math.BigInteger n)
        Compute the list of positive divisors.
        Parameters:
        n - The integer of which the divisors are to be found.
        Returns:
        The sorted list of positive divisors.
        Since:
        2010-08-27
      • sigma

        public static java.math.BigInteger sigma​(java.math.BigInteger n)
        Evaluate sigma(n).
        Parameters:
        n - the argument for which divisors will be searched.
        Returns:
        the sigma function. Sum of the divisors of the argument.
        Since:
        2006-08-14
      • isqrt

        public static int isqrt​(int n)
        Evaluate floor(sqrt(n)).
        Parameters:
        n - The non-negative argument.
        Returns:
        The integer square root. The square root rounded down.
        Since:
        2010-08-27
      • isqrt

        public static long isqrt​(long n)
        Evaluate floor(sqrt(n)).
        Parameters:
        n - The non-negative argument. Arguments less than zero throw an ArithmeticException.
        Returns:
        The integer square root, the square root rounded down.
        Since:
        2010-08-27
      • isqrt

        public static java.math.BigInteger isqrt​(java.math.BigInteger n)
        Evaluate floor(sqrt(n)).
        Parameters:
        n - The non-negative argument. Arguments less than zero throw an ArithmeticException.
        Returns:
        The integer square root, the square root rounded down.
        Since:
        2011-02-12
      • core

        public static java.math.BigInteger core​(java.math.BigInteger n)
        Evaluate core(n). Returns the smallest positive integer m such that n/m is a perfect square.
        Parameters:
        n - The non-negative argument.
        Returns:
        The square-free part of n.
        Since:
        2011-02-12
      • minor

        public static java.math.BigInteger[][] minor​(java.math.BigInteger[][] A,
                                                     int r,
                                                     int c)
                                              throws java.lang.ArithmeticException
        Minor of an integer matrix.
        Parameters:
        A - The matrix.
        r - The row index of the row to be removed (0-based). An exception is thrown if this is outside the range 0 to the upper row index of A.
        c - The column index of the column to be removed (0-based). An exception is thrown if this is outside the range 0 to the upper column index of A.
        Returns:
        The depleted matrix. This is not a deep copy but contains references to the original.
        Throws:
        java.lang.ArithmeticException
        Since:
        2010-08-27
      • det

        public static java.math.BigInteger det​(java.math.BigInteger[][] A)
                                        throws java.lang.ArithmeticException
        Determinant of an integer square matrix.
        Parameters:
        A - The square matrix. If column and row dimensions are unequal, an ArithmeticException is thrown.
        Returns:
        The determinant.
        Throws:
        java.lang.ArithmeticException
        Since:
        2010-08-27
      • solve

        public static Rational[] solve​(java.math.BigInteger[][] A,
                                       java.math.BigInteger[] rhs)
                                throws java.lang.ArithmeticException
        Solve a linear system of equations.
        Parameters:
        A - The square matrix. If it is not of full rank, an ArithmeticException is thrown.
        rhs - The right hand side. The length of this vector must match the matrix size; else an ArithmeticException is thrown.
        Returns:
        The vector of x in A*x=rhs.
        Throws:
        java.lang.ArithmeticException
        Since:
        2010-08-28
      • lcm

        public static java.math.BigInteger lcm​(java.math.BigInteger a,
                                               java.math.BigInteger b)
        The lowest common multiple
        Parameters:
        a - The first argument
        b - The second argument
        Returns:
        lcm(|a|,|b|)
        Since:
        2010-08-27
      • valueOf

        public static java.math.BigInteger valueOf​(java.util.Vector<java.math.BigInteger> c,
                                                   java.math.BigInteger x)
        Evaluate the value of an integer polynomial at some integer argument.
        Parameters:
        c - Represents the coefficients c[0]+c[1]*x+c[2]*x^2+.. of the polynomial
        x - The abscissa point of the evaluation
        Returns:
        The polynomial value.
        Since:
        2010-08-27