Class LinAlg

java.lang.Object
de.labathome.trustconstr.matrix.LinAlg

public final class LinAlg extends Object
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 Details

    • solve

      public static DenseMatrix solve(DenseMatrix A, DenseMatrix b)
      Solve A x = b via LAPACK dgesv (general LU with partial pivoting). A must be square. Inputs are not modified -- the implementation operates on copies.
      Parameters:
      A - square coefficient matrix
      b - right-hand side (A.rows x nrhs); supports multiple RHS
      Returns:
      the solution x (A.rows x nrhs)
    • qr

      public static QRResult qr(DenseMatrix A)
      QR factorisation via dgeqrf + dorgqr. A must be tall-or-square (m >= n).
      Parameters:
      A - m x n matrix to factor
      Returns:
      QRResult with Q (m x n, orthonormal columns) and R (n x n, upper triangular)
    • svd

      public static SVDResult svd(DenseMatrix A)
      Full SVD via dgesvd (jobu='A', jobvt='A'): A = U * diag(s) * V^T.
      Parameters:
      A - m x n matrix to factor
      Returns:
      SVDResult with U (m x m), s (length min(m, n), monotonically non-increasing), and V^T (n x n)
    • cholesky

      public static CholResult cholesky(DenseMatrix A)
      Cholesky factorisation of an SPD matrix via dpotrf, upper triangle. Input is not modified -- implementation operates on a copy.
      Parameters:
      A - square SPD matrix
      Returns:
      CholResult carrying the upper-triangular Cholesky factor in LAPACK column-major layout
    • syr

      public static void syr(DenseMatrix A, double alpha, double[] x)
      In-place rank-1 symmetric update: A := A + alpha x x^T. A must be square; only the upper triangle is updated by BLAS, after which the lower triangle is mirrored from the upper to keep A symmetric.
      Parameters:
      A - square matrix to update in place (n x n)
      alpha - scalar multiplier
      x - length-n vector
    • syr2

      public static void syr2(DenseMatrix A, double alpha, double[] x, double[] y)
      In-place rank-2 symmetric update: A := A + alpha (x y^T + y x^T). A must 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 multiplier
      x - length-n vector
      y - length-n vector