/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final long exponent) { if (exponent == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent < 0) { return new BigFraction(ArithmeticUtils.pow(denominator, -exponent), ArithmeticUtils.pow(numerator, -exponent)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final BigInteger exponent) { if (exponent.signum() == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent.signum() == -1) { final BigInteger eNeg = exponent.negate(); return new BigFraction(ArithmeticUtils.pow(denominator, eNeg), ArithmeticUtils.pow(numerator, eNeg)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * Computes the value (in base 10) represented by the digit * (interpreted in base {@code n}) in the input array in reverse * order. * For example if {@code c} is {@code {3, 2, 1}}, and {@code n} * is 3, the method will return 18. * * @param c Input array. * @return the lexicographic norm. * @throws OutOfRangeException if an element of the array is not * within the interval [0, {@code n}). */ private long lexNorm(int[] c) { long ret = 0; for (int i = 0; i < c.length; i++) { final int digit = c[i]; if (digit < 0 || digit >= n) { throw new OutOfRangeException(digit, 0, n - 1); } ret += c[i] * ArithmeticUtils.pow(n, i); } return ret; } }
for (int j = 1; j <= k; ++j) { sign = -sign; sum += sign * binomialCoefficient(k, j) * ArithmeticUtils.pow(j, n); if (sum < 0) {
/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final long exponent) { if (exponent == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent < 0) { return new BigFraction(ArithmeticUtils.pow(denominator, -exponent), ArithmeticUtils.pow(numerator, -exponent)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final long exponent) { if (exponent == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent < 0) { return new BigFraction(ArithmeticUtils.pow(denominator, -exponent), ArithmeticUtils.pow(numerator, -exponent)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final BigInteger exponent) { if (exponent.signum() == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent.signum() == -1) { final BigInteger eNeg = exponent.negate(); return new BigFraction(ArithmeticUtils.pow(denominator, eNeg), ArithmeticUtils.pow(numerator, eNeg)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * <p> * Returns a <code>BigFraction</code> whose value is * <tt>(this<sup>exponent</sup>)</tt>, returning the result in reduced form. * </p> * * @param exponent * exponent to which this <code>BigFraction</code> is to be raised. * @return <tt>this<sup>exponent</sup></tt> as a <code>BigFraction</code>. */ public BigFraction pow(final BigInteger exponent) { if (exponent.signum() == 0) { return ONE; } if (numerator.signum() == 0) { return this; } if (exponent.signum() == -1) { final BigInteger eNeg = exponent.negate(); return new BigFraction(ArithmeticUtils.pow(denominator, eNeg), ArithmeticUtils.pow(numerator, eNeg)); } return new BigFraction(ArithmeticUtils.pow(numerator, exponent), ArithmeticUtils.pow(denominator, exponent)); }
/** * Computes the value (in base 10) represented by the digit * (interpreted in base {@code n}) in the input array in reverse * order. * For example if {@code c} is {@code {3, 2, 1}}, and {@code n} * is 3, the method will return 18. * * @param c Input array. * @return the lexicographic norm. * @throws OutOfRangeException if an element of the array is not * within the interval [0, {@code n}). */ private long lexNorm(int[] c) { long ret = 0; for (int i = 0; i < c.length; i++) { final int digit = c[i]; if (digit < 0 || digit >= n) { throw new OutOfRangeException(digit, 0, n - 1); } ret += c[i] * ArithmeticUtils.pow(n, i); } return ret; } }
/** * Computes the value (in base 10) represented by the digit * (interpreted in base {@code n}) in the input array in reverse * order. * For example if {@code c} is {@code {3, 2, 1}}, and {@code n} * is 3, the method will return 18. * * @param c Input array. * @return the lexicographic norm. * @throws OutOfRangeException if an element of the array is not * within the interval [0, {@code n}). */ private long lexNorm(int[] c) { long ret = 0; for (int i = 0; i < c.length; i++) { final int digit = c[i]; if (digit < 0 || digit >= n) { throw new OutOfRangeException(digit, 0, n - 1); } ret += c[i] * ArithmeticUtils.pow(n, i); } return ret; } }
private static Tensor[] expandSamples(Tensor[] samples) { //select diff samples: HashSet<Wrapper> set = new HashSet<>(); for (Tensor sample : samples) set.add(new Wrapper(sample)); ArrayList<Tensor> r = new ArrayList<>(); for (Wrapper st : set) { r.ensureCapacity(ArithmeticUtils.pow(2, st.tensor.getIndices().getFree().size())); r.addAll(Arrays.asList(TensorGeneratorUtils.allStatesCombinations(st.tensor))); } return r.toArray(new Tensor[r.size()]); }
static BigInteger findIntegerRoot(BigInteger base, BigInteger power) { BigInteger maxBits = BigInteger.valueOf(base.bitLength() + 1); // base < 2 ^ (maxBits + 1) // => base ^ ( 1 / power ) < 2 ^ ( (maxBits + 1) / power ) BigInteger[] divResult = maxBits.divideAndRemainder(power); if (divResult[1].signum() == 0) // i.e. divResult[1] == 0 maxBits = divResult[0]; else maxBits = divResult[0].add(BigInteger.ONE); if (maxBits.bitLength() > 31) throw new RuntimeException("Too many bits..."); int targetBitsNumber = maxBits.intValue(); int resultLengthM1 = targetBitsNumber / 8 + 1; //resultLength minus one byte[] result = new byte[resultLengthM1]; resultLengthM1--; int bitNumber = targetBitsNumber; int cValue; BigInteger testValue; while ((--bitNumber) >= 0) { //setting bit result[resultLengthM1 - (bitNumber >> 3)] |= 1 << (bitNumber & 0x7); //Testing testValue = new BigInteger(result); cValue = ArithmeticUtils.pow(testValue, power).compareTo(base); if (cValue == 0) return testValue; if (cValue > 0) result[resultLengthM1 - (bitNumber >> 3)] &= ~(1 << (bitNumber & 0x7)); } return null; }
for (int j = 1; j <= k; ++j) { sign = -sign; sum += sign * binomialCoefficient(k, j) * ArithmeticUtils.pow(j, n); if (sum < 0) {
ArrayList<Tensor> samples = new ArrayList<>(ArithmeticUtils.pow(2, metricInds.length)); IntCombinationsGenerator gen; int[] temp;
long factor = ArithmeticUtils.pow((long) 2, count) * ArithmeticUtils.factorial(count + 1);//may be BigInteger? Complex number = new Complex((long) factor).reciprocal(); result = ExpandTransformation.expand(result);