Here you can find the source of diff(List
Parameter | Description |
---|---|
doublesA | the values from which to subtract |
doublesB | the values which shall be subtracted |
public static List<Double> diff(List<Double> doublesA, List<Double> doublesB)
//package com.java2s; /******************************************************************************* * * This file is part of JMad./* w ww .ja v a 2s . c o m*/ * * Copyright (c) 2008-2011, CERN. All rights reserved. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at * * http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. * ******************************************************************************/ import java.util.ArrayList; import java.util.List; public class Main { /** * returns a list with the values difference values doublesA-doublesB * * @param doublesA the values from which to subtract * @param doublesB the values which shall be subtracted * @return a list of differences */ public static List<Double> diff(List<Double> doublesA, List<Double> doublesB) { if (doublesA.size() != doublesB.size()) { throw new IllegalArgumentException("The two lists must be of same size!"); } List<Double> diff = new ArrayList<Double>(doublesA.size()); for (int i = 0; i < doublesA.size(); i++) { diff.add(doublesA.get(i) - doublesB.get(i)); } return diff; } }