Jump to content

QR decomposition: Difference between revisions

m
Minor code improvements.
m (Minor code improvement.)
m (Minor code improvements.)
Line 3,315:
for ( int k = 0; k < columnCount && k < rowCount - 1; k++ ) {
Matrix vectorE = new Matrix(rowCount, new double[rowCount][1] );
z1 = z.minor(k);
Matrix vectorX = z1.column(k);
Line 3,326:
vectorE.setEntry(i, 0, ( i == k ) ? 1 : 0);
}
vectorE = vectorE.scalarMultiply(magnitudeX).add(vectorX).unit();
vectorE = vectorE.unit();
versionsOfQ.add(householderFactor(vectorE));
z = versionsOfQ.get(k).multiply(z1);
Line 3,348 ⟶ 3,347:
final int size = aVector.size();
double[][]Matrix newDataresult = new double[Matrix(size][, size]);
for ( int i = 0; i < size; i++ ) {
for ( int j = 0; j < size; j++ ) {
newData[result.setEntry(i][j], =j, -2 * aVector.getEntry(i, 0) * aVector.getEntry(j, 0));
}
}
for ( int i = 0; i < size; i++ ) {
result.setEntry(i, i, newData[result.getEntry(i][, i]) += 1.0);
}
return new Matrix(newData)result;
}
Line 3,411 ⟶ 3,410:
}
public Matrix(int aRowsaRowCount, int aColsaColumnCount) {
this( new double[aRowsaRowCount][aColsaColumnCount] );
}
 
Line 3,469 ⟶ 3,468:
}
public Matrix column(int aColumnaIndex) {
Matrix result = new Matrix(rowCount, 1);
for ( int i = 0; i < rowCount; i++ ) {
result.setEntry(i, 0, data[i][aColumnaIndex]);
}
return result;
Line 3,483 ⟶ 3,482:
Matrix result = new Matrix(rowCount, columnCount);
for ( int i = 0; i < data.lengthrowCount; i++ ) {
result.data[i][0] = data[i][0] * aValue;
}
Line 3,496 ⟶ 3,495:
final double magnitude = magnitude();
Matrix result = new Matrix(rowCount, columnCount);
for ( int i = 0; i < data.lengthrowCount; i++ ) {
result.data[i][0] = data[i][0] / magnitude;
}
Line 3,518 ⟶ 3,517:
throw new IllegalArgumentException("Incompatible matrix dimensions.");
}
return data.lengthrowCount;
}
Line 3,532 ⟶ 3,531:
}
public double getEntry(int aRow, int aColaColumn) {
return data[aRow][aColaColumn];
}
public void setEntry(int aRow, int aColaColumn, double aValue) {
data[aRow][aColaColumn] = aValue;
}
895

edits

Cookies help us deliver our services. By using our services, you agree to our use of cookies.