Here you can find the source of divide(double[][] arr1, double[][] arr2)
Parameter | Description |
---|---|
arr1 | a parameter |
arr2 | a parameter |
public static double[][] divide(double[][] arr1, double[][] arr2)
//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; } }