Package de.labathome.trustconstr.matrix
Class LinAlg
java.lang.Object
de.labathome.trustconstr.matrix.LinAlg
Thin static facade over
dev.ludovic.netlib BLAS / LAPACK kernels,
specialised to DenseMatrix (column-major double[]). All
routines pass DenseMatrix.data() straight to the native call -- no
row-major / column-major conversion, no extra allocation beyond the working
buffer that LAPACK overwrites.
Each routine documents whether it modifies the input. Where it does, the implementation copies the buffer first so callers don't need to defensively copy at every site.
-
Method Summary
Modifier and TypeMethodDescriptionstatic CholResultCholesky factorisation of an SPD matrix viadpotrf, upper triangle.static QRResultqr(DenseMatrix A) QR factorisation viadgeqrf+dorgqr.static DenseMatrixsolve(DenseMatrix A, DenseMatrix b) SolveA x = bvia LAPACKdgesv(general LU with partial pivoting).static SVDResultsvd(DenseMatrix A) Full SVD viadgesvd(jobu='A',jobvt='A'):A = U * diag(s) * V^T.static voidsyr(DenseMatrix A, double alpha, double[] x) In-place rank-1 symmetric update:A := A + alpha x x^T.static voidsyr2(DenseMatrix A, double alpha, double[] x, double[] y) In-place rank-2 symmetric update:A := A + alpha (x y^T + y x^T).
-
Method Details
-
solve
SolveA x = bvia LAPACKdgesv(general LU with partial pivoting).Amust be square. Inputs are not modified -- the implementation operates on copies.- Parameters:
A- square coefficient matrixb- right-hand side (A.rows x nrhs); supports multiple RHS- Returns:
- the solution
x(A.rows x nrhs)
-
qr
QR factorisation viadgeqrf+dorgqr.Amust be tall-or-square (m >= n).- Parameters:
A-m x nmatrix to factor- Returns:
QRResultwithQ(m x n, orthonormal columns) andR(n x n, upper triangular)
-
svd
Full SVD viadgesvd(jobu='A',jobvt='A'):A = U * diag(s) * V^T.- Parameters:
A-m x nmatrix to factor- Returns:
SVDResultwithU(m x m),s(lengthmin(m, n), monotonically non-increasing), andV^T(n x n)
-
cholesky
Cholesky factorisation of an SPD matrix viadpotrf, upper triangle. Input is not modified -- implementation operates on a copy.- Parameters:
A- square SPD matrix- Returns:
CholResultcarrying the upper-triangular Cholesky factor in LAPACK column-major layout
-
syr
In-place rank-1 symmetric update:A := A + alpha x x^T.Amust be square; only the upper triangle is updated by BLAS, after which the lower triangle is mirrored from the upper to keepAsymmetric.- Parameters:
A- square matrix to update in place (n x n)alpha- scalar multiplierx- length-nvector
-
syr2
In-place rank-2 symmetric update:A := A + alpha (x y^T + y x^T).Amust be square; only the upper triangle is updated, and the lower triangle is mirrored from the upper afterwards.- Parameters:
A- square matrix to update in place (n x n)alpha- scalar multiplierx- length-nvectory- length-nvector
-