Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Hessemberg decomposition dense real #46

Merged
merged 2 commits into from
Jan 11, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,12 @@ public ComplexHessembergDecompositionDense(ComplexMatrixDense A) {
ComplexHouseholderTransformations.au(U, u, 0, U.getRowCount() - 1, k + 1, U.getColumnCount() - 1, work);
}
}

public ComplexMatrixDense getH() {
return H;
}

public ComplexMatrixDense getU() {
return U;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ public static Complex[] genc(ComplexMatrixDense A, int r1, int r2, int c)
scale.multiplyEquals(t);
}

t = Complex.fromReal(1).divide(scale).uminus();;
t = Complex.fromReal(1).divide(scale).uminus();
A.unsafeSet(r1, c, t);

for (i = 0; i < ru; i++) {
Expand Down
Original file line number Diff line number Diff line change
@@ -0,0 +1,59 @@
package com.wildbitsfoundry.etk4j.math.linearalgebra;

import com.wildbitsfoundry.etk4j.math.complex.Complex;
import com.wildbitsfoundry.etk4j.util.ComplexArrays;

/**
* Zhess implements the unitary reduction to Hessenberg form
* by a unitary similarity transformation. Specifically, given
* a square matrix A, there is a unitary matrix U such that
* <pre>
* H = U^H AU
* </pre>
* is upper Hessenberg.
* Zhess represents U and H as Zmats.
*
* @version Pre-alpha
* @author G. W. Stewart
*/
public class HessembergDecompositionDense {

/** The upper Hessenberg matrix */
public MatrixDense H;

/** The unitary matrix */
public MatrixDense U;

/** Creates a Zhess from a square Zmat. Throws a
* JampackException for nonsquare matrx.
*
* @param A A Zmat
* Thrown if A is not square.
*/
public HessembergDecompositionDense(MatrixDense A) {

if (A.getRowCount() != A.getColumnCount()) {
//throw new JampackException("Matrix not square"); TODO
}

H = new MatrixDense(A);
U = MatrixDense.Factory.identity(H.getRowCount());

double[] work = new double[H.getRowCount()];

for (int k = 0; k < H.getColumnCount() - 2; k++) {
double[] u = HouseholderTransformations.genc(H, k + 1, H.getRowCount() - 1, k);
HouseholderTransformations.ua(u, H, k + 1, H.getRowCount() - 1, k + 1, H.getColumnCount() - 1, work);
HouseholderTransformations.au(H, u, 0, H.getRowCount() - 1, k + 1, H.getColumnCount() - 1, work);
HouseholderTransformations.au(U, u, 0, U.getRowCount() - 1, k + 1, U.getColumnCount() - 1, work);
}
}

public MatrixDense getH() {
return H;
}

public MatrixDense getU() {
return U;
}
}
Loading