Java Array Divide arrayDivide(double[] d1, double denominator)

Here you can find the source of arrayDivide(double[] d1, double denominator)

Description

Divides each element of an array by a number.

License

Open Source License

Parameter

Parameter Description
d1 the first array
denominator the denominator for the devision

Return

d1 / denominator

Declaration

public static double[] arrayDivide(double[] d1, double denominator) 

Method Source Code

//package com.java2s;
/** A collection of mathematical utility functions.
 * <p>/*from  w  w w  .  j a v  a2s  .c  o m*/
 * Copyright (c) 2008 Eric Eaton
 * <p>
 * This program is free software: you can redistribute it and/or modify
 * it under the terms of the GNU General Public License as published by
 * the Free Software Foundation, either version 3 of the License, or
 * (at your option) any later version.
 * <p>
 * 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 General Public License for more details.
 * <p>
 * You should have received a copy of the GNU General Public License
 * along with this program.  If not, see http://www.gnu.org/licenses/.
 *
 * @author Eric Eaton (EricEaton@umbc.edu) <br>
 *         University of Maryland Baltimore County
 *
 * @version 0.1
 *
 */

public class Main {
    /** Divides each element of an array by a number.
     * @param d1 the first array
     * @param denominator the denominator for the devision
     * @return d1 / denominator
     */
    public static double[] arrayDivide(double[] d1, double denominator) {
        if (d1 == null) {
            throw new IllegalArgumentException("Array cannot be null.");
        }
        double[] dDivide = new double[d1.length];
        for (int i = 0; i < d1.length; i++) {
            dDivide[i] = d1[i] / denominator;
        }
        return dDivide;
    }
}

Related

  1. arrayDivide(double[] a, double[] b)
  2. arrayDivision(double[] array, double number)
  3. div(double a, double[] b)
  4. div(final int[] result, final int[] vector, final int[] scale)
  5. div(float[] items, int offset, int length, float divisor)