Here you can find the source of divide(double[] dividend, double[] divisor, double dividendAdjustment, double divisorAdjustment)
Parameter | Description |
---|---|
dividend | adjustment |
divisor | adjustment |
Parameter | Description |
---|---|
IllegalArgumentException | if the two argument arrays are not the same length |
public static double[] divide(double[] dividend, double[] divisor, double dividendAdjustment, double divisorAdjustment)
//package com.java2s; /* --------------------------------------------------------------------- * Numenta Platform for Intelligent Computing (NuPIC) * Copyright (C) 2014, Numenta, Inc. Unless you have an agreement * with Numenta, Inc., for a separate license for this software code, the * following terms and conditions apply: * * This program is free software: you can redistribute it and/or modify * it under the terms of the GNU Affero Public License version 3 as * published by the Free Software Foundation. * * This program 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 Affero Public License for more details. * * You should have received a copy of the GNU Affero Public License * along with this program. If not, see http://www.gnu.org/licenses. * * http://numenta.org/licenses/// w w w . j a v a2 s . com * --------------------------------------------------------------------- */ public class Main { /** * Returns an array whose members are the quotient of the dividend array * values and the divisor array values. * * @param dividend * @param divisor * @param dividend adjustment * @param divisor adjustment * * @return * @throws IllegalArgumentException if the two argument arrays are not the same length */ public static double[] divide(double[] dividend, double[] divisor, double dividendAdjustment, double divisorAdjustment) { if (dividend.length != divisor.length) { throw new IllegalArgumentException("The dividend array and the divisor array must be the same length"); } double[] quotient = new double[dividend.length]; double denom = 1; for (int i = 0; i < dividend.length; i++) { quotient[i] = (dividend[i] + dividendAdjustment) / ((denom = divisor[i] + divisorAdjustment) == 0 ? 1 : denom); //Protect against division by 0 } return quotient; } /** * Returns an array whose members are the quotient of the dividend array * values and the divisor array values. * * @param dividend * @param divisor * @param dividend adjustment * @param divisor adjustment * * @return * @throws IllegalArgumentException if the two argument arrays are not the same length */ public static double[] divide(int[] dividend, int[] divisor) { if (dividend.length != divisor.length) { throw new IllegalArgumentException("The dividend array and the divisor array must be the same length"); } double[] quotient = new double[dividend.length]; double denom = 1; for (int i = 0; i < dividend.length; i++) { quotient[i] = (dividend[i]) / (double) ((denom = divisor[i]) == 0 ? 1 : denom); //Protect against division by 0 } return quotient; } /** * Returns an array whose members are the quotient of the dividend array * values and the divisor value. * * @param dividend * @param divisor * @param dividend adjustment * @param divisor adjustment * * @return * @throws IllegalArgumentException if the two argument arrays are not the same length */ public static double[] divide(double[] dividend, double divisor) { double[] quotient = new double[dividend.length]; double denom = 1; for (int i = 0; i < dividend.length; i++) { quotient[i] = (dividend[i]) / (double) ((denom = divisor) == 0 ? 1 : denom); //Protect against division by 0 } return quotient; } }