Java Array Divide divide(double[][] arr1, double[][] arr2)

Here you can find the source of divide(double[][] arr1, double[][] arr2)

Description

divide

License

Open Source License

Parameter

Parameter Description
arr1 a parameter
arr2 a parameter

Declaration

public static double[][] divide(double[][] arr1, double[][] arr2) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**//  w  w w .j  a  va  2 s .  c o m
     * 
     * @param arr1
     * @param arr2
     * @return
     */
    public static double[][] divide(double[][] arr1, double[][] arr2) {
        double[][] ret = new double[arr1.length][];
        for (int i = 0; i < arr1.length; i++) {
            ret[i] = new double[arr1[i].length];
            for (int j = 0; j < arr1[i].length; j++) {
                if (arr2[i][j] == 0)
                    ret[i][j] = Double.NaN;
                else
                    ret[i][j] = arr1[i][j] / arr2[i][j];
            }
        }
        return ret;
    }

    /**
     * 
     * @param arr1
     * @param arr2
     * @return
     */
    public static double[][] divide(int[][] arr1, int[][] arr2) {
        double[][] ret = new double[arr1.length][];
        for (int i = 0; i < arr1.length; i++) {
            ret[i] = new double[arr1[i].length];
            for (int j = 0; j < arr1[i].length; j++) {
                if (arr2[i][j] == 0)
                    ret[i][j] = 0;
                else
                    ret[i][j] = (double) arr1[i][j] / arr2[i][j];
            }
        }
        return ret;
    }
}

Related

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