Here you can find the source of subtract(final double[] v1, final double[] v2)
public static double[] subtract(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://from w ww.j a v a 2 s . c o 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[] subtract(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++) { result[i] = v1[i] - v2[i]; } return result; } }