Java Array Divide divide(double[][] numerator, double[][] denominator)

Here you can find the source of divide(double[][] numerator, double[][] denominator)

Description

Divides the two arrays.

License

Open Source License

Exception

Parameter Description
NullPointerException if either input or on of it's elements are null;

Declaration

public static double[][] divide(double[][] numerator, double[][] denominator) 

Method Source Code

//package com.java2s;
/*//ww w.j a  v  a 2  s  .c o m
 *  Copyright (C) 2013, Peter Decsi.
 * 
 *  This library is free software: you can redistribute it and/or
 *  modify it under the terms of the GNU Lesser General Public 
 *  License as published by the Free Software Foundation, either 
 *  version 3 of the License, or (at your option) any later version.
 * 
 *  This library is distributed in the hope that it will be useful,
 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
 *  GNU Lesser General Public License for more details.
 * 
 *  You should have received a copy of the GNU General Public License
 *  along with this library.  If not, see <http://www.gnu.org/licenses/>.
 */

public class Main {
    /**
     * Divides the two arrays. The length of the returned array will be
     * equal to the length of the shorter input.
     * 
     * @throws NullPointerException if either input or on of it's elements are null;
     */
    public static double[][] divide(double[][] numerator, double[][] denominator) {
        int size = Math.min(numerator.length, denominator.length);
        double[][] result = new double[size][];
        for (int i = 0; i < size; i++)
            result[i] = divide(numerator[i], denominator[i]);
        return result;
    }

    /**
     * Divides the two vectors. The length of the returned vector will be
     * equal to the length of the shorter input.
     * 
     * @throws NullPointerException if `numerator` or `denominator` is null;
     */
    public static double[] divide(double[] numerator, double[] denominator) {
        int size = Math.min(numerator.length, denominator.length);
        double[] result = new double[size];
        for (int i = 0; i < size; i++)
            result[i] = numerator[i] / denominator[i];
        return result;
    }
}

Related

  1. divide(double[] array, double value)
  2. divide(double[] dividend, double[] divisor, double dividendAdjustment, double divisorAdjustment)
  3. divide(double[] numerator, double[] denominator)
  4. divide(double[] t1, double[] t2)
  5. divide(double[][] arr1, double[][] arr2)
  6. divide(final double[] numerators, final double[] denominators)
  7. divide(final double[] v1, final double[] v2)
  8. divide(float[] array, float divident)
  9. divide(float[][] a, float num)