Here you can find the source of subtract(double[] a, double[] b)
public static double[] subtract(double[] a, double[] b)
//package com.java2s; /**/*from w w w.j a v a 2 s . co m*/ * Copyright 2004-2006 DFKI GmbH. * All Rights Reserved. Use is subject to license terms. * * This file is part of MARY TTS. * * MARY TTS is free software: you can redistribute it and/or modify * it under the terms of the GNU Lesser General Public License as published by * the Free Software Foundation, version 3 of the License. * * This program 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 Lesser General Public License for more details. * * You should have received a copy of the GNU Lesser General Public License * along with this program. If not, see <http://www.gnu.org/licenses/>. * */ public class Main { public static double[] subtract(double[] a, double[] b) { if (a.length != b.length) { throw new IllegalArgumentException("Arrays must be equal length"); } double[] c = new double[a.length]; for (int i = 0; i < a.length; i++) { c[i] = a[i] - b[i]; } return c; } public static double[] subtract(double[] a, double b) { double[] c = new double[a.length]; for (int i = 0; i < a.length; i++) { c[i] = a[i] - b; } return c; } public static double[][] subtract(double[][] x, double[][] y) { double[][] z = null; if (x != null && y != null) { int i, j; assert x.length == y.length; for (i = 0; i < x.length; i++) { assert x[i].length == x[0].length; assert x[i].length == y[i].length; } z = new double[x.length][x[0].length]; for (i = 0; i < x.length; i++) { for (j = 0; j < x[i].length; j++) z[i][j] = x[i][j] - y[i][j]; } } return z; } public static float[] subtract(float[] a, float[] b) { if (a.length != b.length) { throw new IllegalArgumentException("Arrays must be equal length"); } float[] c = new float[a.length]; for (int i = 0; i < a.length; i++) { c[i] = a[i] - b[i]; } return c; } public static float[] subtract(float[] a, float b) { float[] c = new float[a.length]; for (int i = 0; i < a.length; i++) { c[i] = a[i] - b; } return c; } }