From 654e3e8a935e3eef1a0d99913dbed968be0dd0e2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Andreas=20Dr=C3=A4ger?= Date: Tue, 31 Aug 2010 17:07:56 +0000 Subject: [PATCH] A new function for vector scaling and addition. --- src/eva2/tools/math/Mathematics.java | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/src/eva2/tools/math/Mathematics.java b/src/eva2/tools/math/Mathematics.java index 068f7563..244a9ebf 100644 --- a/src/eva2/tools/math/Mathematics.java +++ b/src/eva2/tools/math/Mathematics.java @@ -1156,6 +1156,21 @@ public class Mathematics { res[i] = s * v[i] + w[i]; } } + + /** + * Add vectors scaled: res[i] = s*(v[i] + w[i]) + * + * @param s + * @param v + * @param w + * @return + */ + public static void svvAddAndScale(double s, double[] v, double[] w, + double[] res) { + for (int i = 0; i < v.length; i++) { + res[i] = s * (v[i] + w[i]); + } + } /** * Add vectors returning a new vector c = a + b; @@ -1297,7 +1312,7 @@ public class Mathematics { * @param vec */ public static void scale(double scale, double[] vec) { - for (int i=0; i