Class FluidTools

java.lang.Object
jline.lib.butools.mam.FluidTools

public final class FluidTools extends Object
Small matrix helpers shared by the fluid-queue ports (diagonal extraction, index-based submatrices, block assembly). Kept package-local to mirror the self-contained BUTools thirdparty style.
  • Method Summary

    Modifier and Type
    Method
    Description
    static Matrix
    Block-diagonal [[A 0];[0 B]].
    static Matrix
    block(Matrix A, Matrix B, Matrix C, Matrix D)
    2x2 block matrix [[A B];[C D]].
    static int[]
    concat(int[] a, int[] b)
    Concatenate two index arrays.
    static double[]
    Diagonal of M as a double array.
    static Matrix
    diagFrom(double[] v)
    Diagonal matrix from a double array.
    static Matrix
    Diagonal matrix from a row/column vector.
    static Matrix[]
    expIntMoments(Matrix M, double L)
    {J0, J1} with J0=int_0^L expm(M u)du, J1=int_0^L u expm(M u)du via nilpotent augmentation.
    static Matrix
    [A B] side by side (handles zero-dimension blocks).
    static Matrix
    integExp(Matrix KA, double L)
    int_0^L expm(KA u) du, robust when KA has a zero eigenvalue (deflation).
    static Matrix[]
    integExp2(Matrix KA, Matrix KB, double L)
    {int_0^L expm(KA u)du, int_0^L expm(KB u)du}, applying deflation to the near-singular one.
    static Matrix
    Solves A*X = B via partial-pivot LU (LAPACK-equivalent accuracy).
    static double
    Minimum modulus of the eigenvalues of M.
    static Matrix
    Left null vector of KA via the CRPSolve algorithm (column, no generator check).
    static Object[]
    orderedSchur(Matrix A, double tol)
    Real Schur decomposition of A reordered so that the eigenvalues appear grouped as [zero real-part, negative real-part, positive real-part], the ordering used by MATLAB's ordschur in the multi-regime fluid solver.
    static Matrix[]
    Real Schur decomposition of A reordered so that eigenvalues with positive real part appear in the leading block, matching MATLAB's ordschur(U,T,'rhp').
    static int[]
    range(int n)
    0..n-1.
    static Matrix
    Row vector of row-sums (each row summed across columns).
    static void
    setCols(Matrix dst, int[] cols, Matrix src)
    Assigns src (rows x |cols|) into the given columns of dst (all rows).
    static void
    setSub(Matrix dst, int[] ri, int[] ci, Matrix src)
    Assigns src into dst at rows ri, cols ci.
    static int[]
    shiftRange(int start, int n)
    start..start+n-1.
    static Matrix
    sub(Matrix M, int[] ri, int[] ci)
    Submatrix M(ri, ci) with index arrays (0-based).
    static Matrix
    Solves the Sylvester equation A*X - X*B = C where A (n x n) and B (m x m) are quasi-upper-triangular (real Schur form), via column-wise back-substitution (Bartels-Stewart), handling 1x1 and 2x2 diagonal blocks of B.
    static Matrix
    Column-major reshape of M into a single column vector.
    static Matrix
    [A; B] stacked (handles zero-dimension blocks).

    Methods inherited from class java.lang.Object

    clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
  • Method Details

    • diagArray

      public static double[] diagArray(Matrix M)
      Diagonal of M as a double array.
    • diagFrom

      public static Matrix diagFrom(double[] v)
      Diagonal matrix from a double array.
    • diagFrom

      public static Matrix diagFrom(Matrix v)
      Diagonal matrix from a row/column vector.
    • sub

      public static Matrix sub(Matrix M, int[] ri, int[] ci)
      Submatrix M(ri, ci) with index arrays (0-based).
    • setSub

      public static void setSub(Matrix dst, int[] ri, int[] ci, Matrix src)
      Assigns src into dst at rows ri, cols ci.
    • setCols

      public static void setCols(Matrix dst, int[] cols, Matrix src)
      Assigns src (rows x |cols|) into the given columns of dst (all rows).
    • hstack

      public static Matrix hstack(Matrix A, Matrix B)
      [A B] side by side (handles zero-dimension blocks).
    • vstack

      public static Matrix vstack(Matrix A, Matrix B)
      [A; B] stacked (handles zero-dimension blocks).
    • block

      public static Matrix block(Matrix A, Matrix B, Matrix C, Matrix D)
      2x2 block matrix [[A B];[C D]].
    • blkdiag

      public static Matrix blkdiag(Matrix A, Matrix B)
      Block-diagonal [[A 0];[0 B]].
    • concat

      public static int[] concat(int[] a, int[] b)
      Concatenate two index arrays.
    • range

      public static int[] range(int n)
      0..n-1.
    • vec

      public static Matrix vec(Matrix M)
      Column-major reshape of M into a single column vector.
    • rowSums

      public static Matrix rowSums(Matrix M)
      Row vector of row-sums (each row summed across columns).
    • nullvec

      public static Matrix nullvec(Matrix KA)
      Left null vector of KA via the CRPSolve algorithm (column, no generator check).
    • minAbsEig

      public static double minAbsEig(Matrix M)
      Minimum modulus of the eigenvalues of M.
    • integExp

      public static Matrix integExp(Matrix KA, double L)
      int_0^L expm(KA u) du, robust when KA has a zero eigenvalue (deflation).
    • integExp2

      public static Matrix[] integExp2(Matrix KA, Matrix KB, double L)
      {int_0^L expm(KA u)du, int_0^L expm(KB u)du}, applying deflation to the near-singular one.
    • expIntMoments

      public static Matrix[] expIntMoments(Matrix M, double L)
      {J0, J1} with J0=int_0^L expm(M u)du, J1=int_0^L u expm(M u)du via nilpotent augmentation.
    • shiftRange

      public static int[] shiftRange(int start, int n)
      start..start+n-1.
    • orderedSchur

      public static Object[] orderedSchur(Matrix A, double tol)
      Real Schur decomposition of A reordered so that the eigenvalues appear grouped as [zero real-part, negative real-part, positive real-part], the ordering used by MATLAB's ordschur in the multi-regime fluid solver. Returns {Z, T, int[]{zeroeig, negeig, poseig}} with Z orthogonal, T quasi-upper-triangular and Z'*A*Z = T.
    • orderedSchurRhp

      public static Matrix[] orderedSchurRhp(Matrix A)
      Real Schur decomposition of A reordered so that eigenvalues with positive real part appear in the leading block, matching MATLAB's ordschur(U,T,'rhp'). Returns {Z, T} with Z orthogonal, T quasi-upper-triangular and Z'*A*Z = T.
    • linsolve

      public static Matrix linsolve(Matrix A, Matrix B)
      Solves A*X = B via partial-pivot LU (LAPACK-equivalent accuracy).
    • triSylvester

      public static Matrix triSylvester(Matrix A, Matrix B, Matrix C)
      Solves the Sylvester equation A*X - X*B = C where A (n x n) and B (m x m) are quasi-upper-triangular (real Schur form), via column-wise back-substitution (Bartels-Stewart), handling 1x1 and 2x2 diagonal blocks of B. Accurate even when A/B are large.