replaced references to RealMatrixImpl

git-svn-id: https://svn.apache.org/repos/asf/commons/proper/math/trunk@728685 13f79535-47bb-0310-9956-ffa450edef68
This commit is contained in:
Luc Maisonobe 2008-12-22 13:28:29 +00:00
parent 46664c3e99
commit b717e8d1c0

View File

@ -106,38 +106,33 @@ class TriDiagonalTransformer implements Serializable {
if (cachedQt == null) { if (cachedQt == null) {
final int m = householderVectors.length; final int m = householderVectors.length;
final double[][] qtData = new double[m][m]; cachedQt = MatrixUtils.createRealMatrix(m, m);
// build up first part of the matrix by applying Householder transforms // build up first part of the matrix by applying Householder transforms
for (int k = m - 1; k >= 1; --k) { for (int k = m - 1; k >= 1; --k) {
final double[] hK = householderVectors[k - 1]; final double[] hK = householderVectors[k - 1];
final double inv = 1.0 / (secondary[k - 1] * hK[k]); final double inv = 1.0 / (secondary[k - 1] * hK[k]);
qtData[k][k] = 1; cachedQt.setEntry(k, k, 1);
if (hK[k] != 0.0) { if (hK[k] != 0.0) {
final double[] qtK = qtData[k];
double beta = 1.0 / secondary[k - 1]; double beta = 1.0 / secondary[k - 1];
qtK[k] = 1 + beta * hK[k]; cachedQt.setEntry(k, k, 1 + beta * hK[k]);
for (int i = k + 1; i < m; ++i) { for (int i = k + 1; i < m; ++i) {
qtK[i] = beta * hK[i]; cachedQt.setEntry(k, i, beta * hK[i]);
} }
for (int j = k + 1; j < m; ++j) { for (int j = k + 1; j < m; ++j) {
final double[] qtJ = qtData[j];
beta = 0; beta = 0;
for (int i = k + 1; i < m; ++i) { for (int i = k + 1; i < m; ++i) {
beta += qtJ[i] * hK[i]; beta += cachedQt.getEntry(j, i) * hK[i];
} }
beta *= inv; beta *= inv;
qtJ[k] = beta * hK[k]; cachedQt.setEntry(j, k, beta * hK[k]);
for (int i = k + 1; i < m; ++i) { for (int i = k + 1; i < m; ++i) {
qtJ[i] += beta * hK[i]; cachedQt.addToEntry(j, i, beta * hK[i]);
} }
} }
} }
} }
qtData[0][0] = 1; cachedQt.setEntry(0, 0, 1);
// cache the matrix for subsequent calls
cachedQt = new RealMatrixImpl(qtData, false);
} }
@ -155,21 +150,17 @@ class TriDiagonalTransformer implements Serializable {
if (cachedT == null) { if (cachedT == null) {
final int m = main.length; final int m = main.length;
double[][] tData = new double[m][m]; cachedT = MatrixUtils.createRealMatrix(m, m);
for (int i = 0; i < m; ++i) { for (int i = 0; i < m; ++i) {
double[] tDataI = tData[i]; cachedT.setEntry(i, i, main[i]);
tDataI[i] = main[i];
if (i > 0) { if (i > 0) {
tDataI[i - 1] = secondary[i - 1]; cachedT.setEntry(i, i - 1, secondary[i - 1]);
} }
if (i < main.length - 1) { if (i < main.length - 1) {
tDataI[i + 1] = secondary[i]; cachedT.setEntry(i, i + 1, secondary[i]);
} }
} }
// cache the matrix for subsequent calls
cachedT = new RealMatrixImpl(tData, false);
} }
// return the cached matrix // return the cached matrix