From 3a751b5acf6e19f13dc2a7dd3c4d2184dc0b12d3 Mon Sep 17 00:00:00 2001 From: Luc Maisonobe Date: Sun, 5 Oct 2008 19:12:05 +0000 Subject: [PATCH] removed unneeded multiplications by zero by separating the first iteration from the following ones in a loop git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/branches/MATH_2_0@701852 13f79535-47bb-0310-9956-ffa450edef68 --- .../commons/math/linear/TriDiagonalTransformer.java | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java b/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java index 6d197abfe..13187f47d 100644 --- a/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java +++ b/src/java/org/apache/commons/math/linear/TriDiagonalTransformer.java @@ -114,9 +114,15 @@ class TriDiagonalTransformer implements Serializable { final double inv = 1.0 / (secondary[k - 1] * hK[k]); qtData[k][k] = 1; if (hK[k] != 0.0) { - for (int j = k; j < m; ++j) { + final double[] qtK = qtData[k]; + double beta = 1.0 / secondary[k - 1]; + qtK[k] = 1 + beta * hK[k]; + for (int i = k + 1; i < m; ++i) { + qtK[i] = beta * hK[i]; + } + for (int j = k + 1; j < m; ++j) { final double[] qtJ = qtData[j]; - double beta = 0; + beta = 0; for (int i = k; i < m; ++i) { beta += qtJ[i] * hK[i]; }