Java Array Difference difference(float[] v1, float[] v2)

Here you can find the source of difference(float[] v1, float[] v2)

Description

difference

License

Open Source License

Declaration

public static float[] difference(float[] v1, float[] v2) 

Method Source Code

//package com.java2s;
/*//from  w w w . j a va  2  s . com
 * Copyright (c) 2008-2013 Maksim Khadkevich and Fondazione Bruno Kessler.
 *
 * This file is part of MART.
 * MART is free software; you can redistribute it and/or modify it
 * under the terms of the GNU General Public License version 2, as published
 * by the Free Software Foundation.
 *
 * MART 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.
 * You should have received a copy of the GNU General Public License
 * along with MART; if not, write to the Free Software Foundation,
 * Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
 */

public class Main {
    public static float[] difference(float[] v1, float[] v2) {
        if (v1.length != v2.length) {
            throw new IllegalArgumentException(
                    "Arrays lengths are different");
        }
        float[] out = new float[v1.length];
        for (int i = 0; i < out.length; i++) {
            out[i] = v1[i] - v2[i];
        }
        return out;
    }
}

Related

  1. difference2D(char[][] first, char[][] second)
  2. difference5D(char[][][][][] first, char[][][][][] second)
  3. differenceFunction(float[] data, int windowLength)