public virtual void test_combineLenient()
 {
     System.Func <double, double, double> @operator = (a, b) => a / b;
     assertThat(DoubleArrayMath.combineLenient(ARRAY_1_2, ARRAY_3_4, @operator)).contains(1d / 3d, 2d / 4d);
     assertThat(DoubleArrayMath.combineLenient(ARRAY_1_2, ARRAY_3, @operator)).contains(1d / 3d, 2d);
     assertThat(DoubleArrayMath.combineLenient(ARRAY_3, ARRAY_1_2, @operator)).contains(3d / 1d, 2d);
 }
 public virtual void test_mutate()
 {
     System.Func <double, double> @operator = a => 1 / a;
     double[] testArray = ARRAY_1_2.Clone();
     DoubleArrayMath.mutate(testArray, @operator);
     assertThat(testArray).contains(1d, 1d / 2d);
 }
 public virtual void test_sortPairs_doubledouble_2()
 {
     double[] keys   = new double[] { 3d, 2d, 5d, 4d };
     double[] values = new double[] { 6d, 4d, 10d, 8d };
     DoubleArrayMath.sortPairs(keys, values);
     assertThat(keys).containsExactly(2d, 3d, 4d, 5d);
     assertThat(values).containsExactly(4d, 6d, 8d, 10d);
 }
 public virtual void test_sortPairs_doubleObject_2()
 {
     double[] keys   = new double[] { 3d, 2d, 5d, 4d };
     int?[]   values = new int?[] { 6, 4, 10, 8 };
     DoubleArrayMath.sortPairs(keys, values);
     assertThat(keys).containsExactly(2d, 3d, 4d, 5d);
     assertThat(values).containsExactly(4, 6, 8, 10);
 }
 public virtual void test_fuzzyEquals()
 {
     assertThat(DoubleArrayMath.fuzzyEquals(DoubleArrayMath.EMPTY_DOUBLE_ARRAY, ARRAY_0_0, 1e-2)).False;
     assertThat(DoubleArrayMath.fuzzyEquals(ARRAY_0_0, ARRAY_0_0, 1e-2)).True;
     assertThat(DoubleArrayMath.fuzzyEquals(ARRAY_1_2, ARRAY_1_2, 1e-2)).True;
     assertThat(DoubleArrayMath.fuzzyEquals(ARRAY_1_2, ARRAY_1_2B, 1e-2)).True;
     assertThat(DoubleArrayMath.fuzzyEquals(ARRAY_1_2, ARRAY_1_2B, 1e-3)).True;
     assertThat(DoubleArrayMath.fuzzyEquals(ARRAY_1_2, ARRAY_1_2B, 1e-4)).False;
 }
        /// <summary>
        /// Multiplies values in two arrays, mutating the first array.
        /// <para>
        /// The arrays must be the same length. Each value in {@code array} is multiplied by the value at the
        /// corresponding index in {@code arrayToMultiplyBy}.
        ///
        /// </para>
        /// </summary>
        /// <param name="array">  the array to mutate </param>
        /// <param name="arrayToMultiplyBy">  the array containing values to multiply by </param>
        public static void mutateByMultiplication(double[] array, double[] arrayToMultiplyBy)
        {
            int length = DoubleArrayMath.length(array, arrayToMultiplyBy);

            for (int i = 0; i < length; i++)
            {
                array[i] *= arrayToMultiplyBy[i];
            }
        }
        /// <summary>
        /// Adds values in two arrays together, mutating the first array.
        /// <para>
        /// The arrays must be the same length. Each value in {@code arrayToAdd} is added to the value at the
        /// corresponding index in {@code array}.
        ///
        /// </para>
        /// </summary>
        /// <param name="array">  the array to mutate </param>
        /// <param name="arrayToAdd">  the array containing values to add </param>
        public static void mutateByAddition(double[] array, double[] arrayToAdd)
        {
            int length = DoubleArrayMath.length(array, arrayToAdd);

            for (int i = 0; i < length; i++)
            {
                array[i] += arrayToAdd[i];
            }
        }
        /// <summary>
        /// Combines two arrays, returning an array where each element is the combination of the two matching inputs.
        /// <para>
        /// Each element in the result will be the combination of the matching index in the two
        /// input arrays using the operator. The two input arrays must have the same length.
        /// </para>
        /// <para>
        /// The result is always a new array. The input arrays are not mutated.
        ///
        /// </para>
        /// </summary>
        /// <param name="array1">  the first array </param>
        /// <param name="array2">  the second array </param>
        /// <param name="operator">  the operator to use when combining values </param>
        /// <returns> an array combining the two input arrays using the operator </returns>
        public static double[] combine(double[] array1, double[] array2, System.Func <double, double, double> @operator)
        {
            int length = DoubleArrayMath.length(array1, array2);

            double[] result = new double[length];
            for (int i = 0; i < length; i++)
            {
                result[i] = @operator(array1[i], array2[i]);
            }
            return(result);
        }
 public virtual void test_mutateByMultiplication_byArray()
 {
     double[] testArray = ARRAY_1_2.Clone();
     DoubleArrayMath.mutateByMultiplication(testArray, new double[] { 4d, 5d });
     assertThat(testArray).contains(4d, 10d);
 }
 public virtual void toObject()
 {
     assertThat(DoubleArrayMath.toObject(new double[] {})).isEqualTo(new double?[] {});
     assertThat(DoubleArrayMath.toObject(new double[] { 1d, 2.5d })).isEqualTo(new double?[] { 1d, 2.5d });
 }
 public virtual void test_mutateByMultiplication_byConstant()
 {
     double[] testArray = ARRAY_1_2.Clone();
     DoubleArrayMath.mutateByMultiplication(testArray, 4d);
     assertThat(testArray).contains(4d, 8d);
 }
 public virtual void test_mutateByAddition_byArray()
 {
     double[] testArray = ARRAY_1_2.Clone();
     DoubleArrayMath.mutateByAddition(testArray, new double[] { 2d, 3d });
     assertThat(testArray).contains(3d, 5d);
 }
 public virtual void test_apply()
 {
     System.Func <double, double> @operator = a => 1 / a;
     assertThat(DoubleArrayMath.apply(ARRAY_1_2, @operator)).contains(1d, 1d / 2d);
 }
 //-------------------------------------------------------------------------
 public virtual void test_mutateByAddition_byConstant()
 {
     double[] testArray = ARRAY_1_2.Clone();
     DoubleArrayMath.mutateByAddition(testArray, 2d);
     assertThat(testArray).contains(3d, 4d);
 }
 public virtual void test_applyMultiplication()
 {
     assertThat(DoubleArrayMath.applyMultiplication(ARRAY_1_2, 4d)).contains(4d, 8d);
 }
 //-------------------------------------------------------------------------
 public virtual void test_applyAddition()
 {
     assertThat(DoubleArrayMath.applyAddition(ARRAY_1_2, 2d)).contains(3d, 4d);
 }
 public virtual void test_combineByMultiplication()
 {
     assertThat(DoubleArrayMath.combineByMultiplication(ARRAY_1_2, ARRAY_3_4)).contains(3d, 8d);
     assertThrowsIllegalArg(() => DoubleArrayMath.combineByMultiplication(ARRAY_1_2, ARRAY_3));
 }
 public virtual void test_combine()
 {
     System.Func <double, double, double> @operator = (a, b) => a / b;
     assertThat(DoubleArrayMath.combine(ARRAY_1_2, ARRAY_3_4, @operator)).contains(1d / 3d, 2d / 4d);
     assertThrowsIllegalArg(() => DoubleArrayMath.combine(ARRAY_1_2, ARRAY_3, @operator));
 }
 public virtual void test_sortPairs_doubleObject_sizeDifferent()
 {
     double[] keys   = new double[] { 3d, 2d, 5d, 4d };
     int?[]   values = new int?[] { 6, 4 };
     assertThrowsIllegalArg(() => DoubleArrayMath.sortPairs(keys, values));
 }
 //-------------------------------------------------------------------------
 public virtual void test_sum()
 {
     assertThat(DoubleArrayMath.sum(ARRAY_1_2)).isEqualTo(3d);
 }
 public virtual void test_mutateByMultiplication_byArray_sizeDifferent()
 {
     double[] testArray = ARRAY_1_2.Clone();
     assertThrowsIllegalArg(() => DoubleArrayMath.mutateByMultiplication(testArray, new double[] { 4d }));
 }