Naive elementwise multiplication: for each element of {@code big}
, find a corresponding element in {@code small} and multiply
them.

@param big
@param small
@return
778587
protected static final SparseTensor elementwiseMultiplyNaive(SparseTensor big, Tensor small) {
    // Compute a mapping from keyNums of big to keyNums of small.
    int[] bigDimensions = big.getDimensionNumbers();
    int[] smallDimensions = small.getDimensionNumbers();
    int[] bigDimensionSizes = big.getDimensionSizes();
    int smallDimensionInd = smallDimensions.length - 1;
    int bigDimensionInd = bigDimensions.length - 1;
    // divisors, modulos and multipliers store the mapping from
    // bigKeyNum to
    // smallKeyNum.
    // They contain a series of division, modulo and multiplication
    // operations
    // whose results are added to get a smallKeyNum.
    long[] divisors = new long[smallDimensions.length];
    long[] modulos = new long[smallDimensions.length];
    long[] multipliers = new long[smallDimensions.length];
    int divisorInd = 0;
    long divisor = 1;
    long multiplier = 1;
    long modulo = 1;
    while (bigDimensionInd >= 0 && smallDimensionInd >= 0) {
      while (bigDimensions[bigDimensionInd] != smallDimensions[smallDimensionInd]) {
        divisor *= bigDimensionSizes[bigDimensionInd];
        bigDimensionInd--;
      }
      divisors[divisorInd] = divisor;

      modulo = 1;
      while (bigDimensionInd >= 0 && smallDimensionInd >= 0 &&
          bigDimensions[bigDimensionInd] == smallDimensions[smallDimensionInd]) {
        divisor *= bigDimensionSizes[bigDimensionInd];
        modulo *= bigDimensionSizes[bigDimensionInd];
        bigDimensionInd--;
        smallDimensionInd--;
      }
      modulos[divisorInd] = modulo;
      multipliers[divisorInd] = multiplier;
      divisorInd++;
      multiplier *= modulo;
    }

    // The result tensor is no larger than the larger (superset of
    // dimensions)
    // tensor.
    long[] resultKeyInts = new long[big.size()];
    double[] resultValues = new double[big.size()];
    // How many result values have been filled so far.
    int resultInd = 0;

    long bigKeyNum, smallKeyNum;
    double value;
    int numElements = big.size();
    for (int bigInd = 0; bigInd < numElements; bigInd++) {
      bigKeyNum = big.indexToKeyNum(bigInd);
      // map bigKeyNum to a smallKeyNum
      smallKeyNum = 0;
      for (int i = 0; i < divisorInd; i++) {
        smallKeyNum += ((bigKeyNum / divisors[i]) % modulos[i]) * multipliers[i];
      }
      value = small.get(smallKeyNum);

      if (value != 0.0) {
        resultKeyInts[resultInd] = bigKeyNum;
        resultValues[resultInd] = value * big.getByIndex(bigInd);
        resultInd++;
      }
    }

    return resizeIntoTable(big.getDimensionNumbers(), big.getDimensionSizes(), resultKeyInts,
        resultValues, resultInd);
  }
958778
public static double combination(int n, int k) {
        if(n<k) {
            throw new IllegalArgumentException("The n can't be smaller than k.");
        }
        double combinations=1.0;
        double lowerBound = n-k;
        for(int i=n;i>lowerBound;i--) {
            combinations *= i/(i-lowerBound);
        }
        return combinations;
    }
814243
public BigInteger getBigInteger(int index) throws JSONException {
		Object object = this.get(index);
		try {
			return new BigInteger(object.toString());
		} catch (Exception e) {
			throw new JSONException("JSONArray[" + index +
					"] could not convert to BigInteger.");
		}
	}
118826
public BigComplex multiply(BigComplex value) {
		return valueOf(
				re.multiply(value.re).subtract(im.multiply(value.im)),
				re.multiply(value.im).add(im.multiply(value.re)));
	}
1049629
void multiply(MutableBigInteger y, MutableBigInteger z) {
        int xLen = intLen;
        int yLen = y.intLen;
        int newLen = xLen + yLen;

        // Put z into an appropriate state to receive product
        if (z.value.length < newLen)
            z.value = new int[newLen];
        z.offset = 0;
        z.intLen = newLen;

        // The first iteration is hoisted out of the loop to avoid extra add
        long carry = 0;
        for (int j=yLen-1, k=yLen+xLen-1; j >= 0; j--, k--) {
                long product = (y.value[j+y.offset] & LONG_MASK) *
                               (value[xLen-1+offset] & LONG_MASK) + carry;
                z.value[k] = (int)product;
                carry = product >>> 32;
        }
        z.value[xLen-1] = (int)carry;

        // Perform the multiplication word by word
        for (int i = xLen-2; i >= 0; i--) {
            carry = 0;
            for (int j=yLen-1, k=yLen+i; j >= 0; j--, k--) {
                long product = (y.value[j+y.offset] & LONG_MASK) *
                               (value[i+offset] & LONG_MASK) +
                               (z.value[k] & LONG_MASK) + carry;
                z.value[k] = (int)product;
                carry = product >>> 32;
            }
            z.value[i] = (int)carry;
        }

        // Remove leading zeros from product
        z.normalize();
    }
587029
public PackedDecimal multiply(BigDecimal operand) {
        BigDecimal produkt = toBigDecimal().multiply(operand);
        return PackedDecimal.valueOf(produkt);
    }
1193890
private static BigDecimal doRound(BigInteger intVal, int scale, MathContext mc) {
        int mcp = mc.precision;
        int prec = 0;
        if (mcp > 0) {
            long compactVal = compactValFor(intVal);
            int mode = mc.roundingMode.oldMode;
            int drop;
            if (compactVal == INFLATED) {
                prec = bigDigitLength(intVal);
                drop = prec - mcp;
                while (drop > 0) {
                    scale = checkScaleNonZero((long) scale - drop);
                    intVal = divideAndRoundByTenPow(intVal, drop, mode);
                    compactVal = compactValFor(intVal);
                    if (compactVal != INFLATED) {
                        break;
                    }
                    prec = bigDigitLength(intVal);
                    drop = prec - mcp;
                }
            }
            if (compactVal != INFLATED) {
                prec = longDigitLength(compactVal);
                drop = prec - mcp;     // drop can't be more than 18
                while (drop > 0) {
                    scale = checkScaleNonZero((long) scale - drop);
                    compactVal = divideAndRound(compactVal, LONG_TEN_POWERS_TABLE[drop], mc.roundingMode.oldMode);
                    prec = longDigitLength(compactVal);
                    drop = prec - mcp;
                }
                return valueOf(compactVal,scale,prec);
            }
        }
        return new BigDecimal(intVal,INFLATED,scale,prec);
    }
690618
public static <T> Level0ArrayOperator<Double[],Double> onArrayFor(final Double... elements) {
        return onArrayOf(Types.DOUBLE, VarArgsUtil.asRequiredObjectArray(elements));
    }
226227
public static <K> Matcher<Multimap<K, ?>> keyWithSize(final K element, final int size) {
        return new IsMultimapKeyWithCollectionSize(element, size);
    }
1109600
public static <T> Set<Set<T>> combinations(Set<T> elements, int subsetSize) {
        return combinationsStream(elements, subsetSize).collect(Collectors.toSet());
    }
544910
private static boolean isBigInteger( Number n ) {
      if( n instanceof BigInteger ){
         return true;
      }
      try{
         new BigInteger( String.valueOf( n ) );
         return true;
      }catch( NumberFormatException e ){
         return false;
      }
   }
1009290
public static BigDecimal sum(final Iterable<? extends Number> target) {
        Validate.notNull(target, "Cannot aggregate on null");
        Validate.containsNoNulls(target, "Cannot aggregate on iterable containing nulls");
        BigDecimal total = BigDecimal.ZERO;
        int size = 0;
        for (final Number element : target) {
            total = total.add(toBigDecimal(element));
            size++;
        }
        if (size == 0) {
            return null;
        }
        return total;
    }
1308436
public BigDecimal add(BigDecimal augend) {
        if (this.intCompact != INFLATED) {
            if ((augend.intCompact != INFLATED)) {
                return add(this.intCompact, this.scale, augend.intCompact, augend.scale);
            } else {
                return add(this.intCompact, this.scale, augend.intVal, augend.scale);
            }
        } else {
            if ((augend.intCompact != INFLATED)) {
                return add(augend.intCompact, augend.scale, this.intVal, this.scale);
            } else {
                return add(this.intVal, this.scale, augend.intVal, augend.scale);
            }
        }
    }
788279
public static BigInteger toBigInteger(Object value, BigInteger defaultValue) {
		return convert(BigInteger.class, value, defaultValue);
	}
1086111
public Permutation multiply(Permutation other) {
        Permutation newPermutation = new Permutation(values.length);
        for (int i = 0; i < values.length; i++) {
            newPermutation.values[i] = this.values[other.values[i]];
        }
        return newPermutation;
    }
1065653
Set<E> union(final SmallSet<E> s) {
        if ((s.e1 == e1 && s.e2 == e2) || (s.e1 == e2 && s.e2 == e1)) {
            return this; // if the two sets are equal, return this
        }
        if (s.e1 == null) {
            return this; // if s is empty, return this
        }
        if (e1 == null) {
            return s; // if this is empty, return s
        }
        if (s.e2 == null) { // s contains exactly one element
            if (e2 == null) {
                return new SmallSet<E>(e1, s.e1); // necessarily e1 != s.e1
            } else if (s.e1 == e1 || s.e1 == e2) { // s is included in this
                return this;
            }
        }
        if (e2 == null) { // this contains exactly one element
            // if (s.e2 == null) { // cannot happen
            // return new SmallSet(e1, s.e1); // necessarily e1 != s.e1
            // } else
            if (e1 == s.e1 || e1 == s.e2) { // this in included in s
                return s;
            }
        }
        // here we know that there are at least 3 distinct elements
        HashSet<E> r = new HashSet<E>(4);
        r.add(e1);
        if (e2 != null) {
            r.add(e2);
        }
        r.add(s.e1);
        if (s.e2 != null) {
            r.add(s.e2);
        }
        return r;
    }
1100664
BigDecimal toBigDecimal(int sign, int scale) {
        if (intLen == 0 || sign == 0)
            return BigDecimal.zeroValueOf(scale);
        int[] mag = getMagnitudeArray();
        int len = mag.length;
        int d = mag[0];
        // If this MutableBigInteger can't be fit into long, we need to
        // make a BigInteger object for the resultant BigDecimal object.
        if (len > 2 || (d < 0 && len == 2))
            return new BigDecimal(new BigInteger(mag, sign), INFLATED, scale, 0);
        long v = (len == 2) ?
            ((mag[1] & LONG_MASK) | (d & LONG_MASK) << 32) :
            d & LONG_MASK;
        return BigDecimal.valueOf(sign == -1 ? -v : v, scale);
    }