Here you can find the source of divide(long[] array, double value)
Parameter | Description |
---|---|
array | Input array |
value | Scalar |
public static double[] divide(long[] array, double value)
//package com.java2s; /******************************************************************************* * Copyright (c) 2016 Pablo Pavon-Marino. * All rights reserved. This program and the accompanying materials * are made available under the terms of the GNU Lesser Public License v2.1 * which accompanies this distribution, and is available at * http://www.gnu.org/licenses/lgpl.html * * Contributors://from ww w. j a v a 2 s . c o m * Pablo Pavon-Marino - Jose-Luis Izquierdo-Zaragoza, up to version 0.3.1 * Pablo Pavon-Marino - from version 0.4.0 onwards ******************************************************************************/ public class Main { /** * Divides all elements in an array by a scalar. * * @param array Input array * @param value Scalar * @return A new array containing the input elements divided by the scalar * */ public static double[] divide(long[] array, double value) { double[] out = new double[array.length]; for (int i = 0; i < out.length; i++) { out[i] = array[i] / value; } return out; } /** * Divides two arrays element-to-element. * * @param array1 Numerator * @param array2 Denominator * @return The element-wise division of the input arrays * */ public static double[] divide(long[] array1, long[] array2) { double[] out = new double[array1.length]; for (int i = 0; i < out.length; i++) out[i] = (double) array1[i] / array2[i]; return out; } }