Here you can find the source of divide(final double[] v1, final double[] v2)
public static double[] divide(final double[] v1, final double[] v2)
//package com.java2s; /******************************************************************************* * Copyright (c) 2015 Vienna University of Technology. * All rights reserved. This program and the accompanying materials * are made available under the terms of the Eclipse Public License v1.0 * which accompanies this distribution, and is available at * http://www.eclipse.org/legal/epl-v10.html * * Contributors:// w w w . j a v a 2s . co m * Martin Fleck (Vienna University of Technology) - initial API and implementation * * Initially developed in the context of ARTIST EU project www.artist-project.eu *******************************************************************************/ public class Main { private static final String VECTORS_DIFFERENT_LENGTHS = "Vector v1 and v2 have different lengths"; public static double[] divide(final double[] v1, final double[] v2) { if (v1.length != v2.length) { throw new RuntimeException(VECTORS_DIFFERENT_LENGTHS); } final double[] result = new double[v1.length]; for (int i = 0; i < result.length; i++) { if (v2[i] != 0) { result[i] = v1[i] / v2[i]; } else if (v1[i] < 0) { result[i] = Double.NEGATIVE_INFINITY; } else { result[i] = Double.POSITIVE_INFINITY; } } return result; } }