Skip to content

Implement comprehensive BLAS, ARPACK, and LAPACK test coverage#34

Draft
luhenry wants to merge 8 commits intomasterfrom
moar-testing
Draft

Implement comprehensive BLAS, ARPACK, and LAPACK test coverage#34
luhenry wants to merge 8 commits intomasterfrom
moar-testing

Conversation

@luhenry
Copy link
Owner

@luhenry luhenry commented Feb 14, 2026

No description provided.

luhenry and others added 6 commits February 14, 2026 15:19
Add test implementations for previously stubbed BLAS routines across both
single and double precision variants, including band matrix operations
(gbmv, sbmv, tbmv, tbsv), triangular operations (tpmv, tpsv, trmm, trmv,
trsm, trsv), symmetric rank-k updates (syr2k, syrk), and modified rotation
operations (rotm, rotmg). Enhance BLASTest base class with band matrix
extraction utilities and relative error assertions to support these tests.
Add complete test implementations for all 58 ARPACK test classes, replacing
placeholder stubs with functional tests that validate eigenvalue solver
routines against the F2j reference implementation. Tests cover utility
functions, sorting operations, QR algorithms, Arnoldi iterations, and both
symmetric and non-symmetric eigenvalue solvers.

Enhance ARPACKTest base class with test data generation utilities, including
symmetric matrices, integer/double/float arrays, and custom assertion methods
for array comparisons. Add support for reverse communication patterns (IDO)
and org.netlib.util wrapper types (intW, doubleW, floatW).

Test categories implemented:
- Integer utilities: icopy, iset, iswap, icnteq, ivout (5 tests)
- Output functions: dvout, dmout, svout, smout (4 tests)
- Sorting: dsortr, dsortc, ssortr, ssortc (4 tests)
- Statistics: dstatn, dstats, sstatn, sstats (4 tests)
- QR algorithms: dstqrb, sstqrb, dlaqrb, slaqrb (4 tests)
- Vector generation: dgetv0, sgetv0 (2 tests)
- Timing: second (1 test)
- Symmetric eigenvalue solvers: 18 test classes (dsconv, dseigt, dsesrt,
  dsgets, dsapps, dsaitr, dsaup2, dsaupd, dseupd + float variants)
- Non-symmetric eigenvalue solvers: 18 test classes (dnconv, dneigh, dngets,
  dnapps, dnaitr, dnaup2, dnaupd, dneupd + float variants)

Of 640 tests, 619 passes successfully across all the ARPACK implementations,
21 are still skipped as they trigger crashes in the native implementations.
Implemented comprehensive test coverage for TIER 1 LAPACK routines (19 test files):

**Utilities (3 files):**
- Ilaenv: Environment tuning parameters (block sizes)
- Lsame: Case-insensitive character comparison
- Lsamen: Case-insensitive n-character string comparison

**Machine Constants - Double Precision (6 files):**
- Dlamch: Machine parameter retrieval (epsilon, safe minimum, base, precision)
- Dlamc1-5: Internal machine constant determination routines

**Machine Constants - Single Precision (6 files):**
- Slamch: Single precision machine parameters
- Slamc1-5: Internal single precision constant determination

**NaN Detection (4 files):**
- Disnan, Sisnan: NaN detection for double/single precision
- Dlaisnan, Slaisnan: NaN comparison for double/single precision

**Test Infrastructure:**
- Enhanced LAPACKTest base class with test data generators and assertion helpers
- Added matrix/vector generation utilities (general, symmetric, positive definite)
- Implemented proper handling of internal routines using assumeFalse for NativeLAPACK

**Test Results:** 50 tests run, 0 failures, 0 errors, 6 skipped (internal routines)
Tests validate all implementations against F2jLAPACK reference implementation.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Implemented comprehensive test coverage for TIER 2 LAPACK routines (26 test files):

**Safe Pythagorean Operations (4 files):**
- Dlapy2, Slapy2: Safe sqrt(x²+y²) without overflow/underflow
- Dlapy3, Slapy3: Safe sqrt(x²+y²+z²) without overflow/underflow

**2x2 Matrix Problems (8 files):**
- Dlae2, Slae2: 2x2 symmetric eigenvalue decomposition (eigenvalues only)
- Dlaev2, Slaev2: 2x2 symmetric eigenvalue with eigenvectors
- Dlas2, Slas2: Singular values of 2x2 triangular matrix
- Dlasv2, Slasv2: Complete SVD of 2x2 general matrix

**Rotation Generation (4 files):**
- Dlartg, Slartg: Generate Givens plane rotation
- Dlarfg, Slarfg: Generate elementary Householder reflector

**Complex Matrix Operations (6 files):**
- Dlanv2, Slanv2: Standardize 2x2 real Schur block
- Dlag2, Slag2: Eigenvalues of 2x2 generalized eigenvalue problem
- Dlags2, Slags2: Compute sine/cosine for generalized eigenvalue problem

**Miscellaneous Utilities (4 files):**
- Dlamrg, Slamrg: Merge two sorted lists into one
- Dlarra, Slarra: Compute splitting points for tridiagonal eigenvalue

**Test Results:** 130 tests run, 0 failures, 0 errors, 0 skipped
All implementations validated against F2jLAPACK reference implementation.

These elementary math functions are fundamental building blocks used throughout
LAPACK for factorizations, eigenvalue solvers, and SVD algorithms.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…tions

Implemented comprehensive test coverage for TIER 3 LAPACK routines (26 test files):

**Copy Operations (2 files):**
- Dlacpy, Slacpy: Copy matrices with format conversion (full, upper, lower triangular)

**Scale/Set Operations (6 files):**
- Dlascl, Slascl: Scale matrix by scalar with various matrix types
- Dlaset, Slaset: Set matrix to constant values or identity
- Dlabad, Slabad: Compute safe scaling bounds

**Permutation/Swap Operations (6 files):**
- Dlapmt, Slapmt: Permute matrix columns (forward/backward)
- Dlaswp, Slaswp: Swap matrix rows (forward/backward)
- Dlacn2, Slacn2: Estimate matrix 1-norm using reverse communication

**Eigenvalue Utility Operations (12 files):**
- Dlarrc, Slarrc: Count eigenvalues in specified interval
- Dlarrd, Slarrd: Compute eigenvalue clusters for divide-and-conquer
- Dlarre, Slarre: Compute representation tree for eigenvalues (MRRR algorithm)
- Dlarrj, Slarrj: Refine eigenvalue subset using bisection
- Dlarrk, Slarrk: Compute one eigenvalue by bisection
- Dlarrr, Slarrr: Test relative representation for eigenvalue accuracy

**Test Results:** 130 tests run, 94 passed, 36 skipped, 0 failures, 0 errors
Internal eigenvalue utility routines skip NativeLAPACK (not exposed in native API).

These operations are fundamental for matrix manipulation, equilibration, and
eigenvalue computations throughout LAPACK.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
…mbers

Implemented comprehensive test coverage for TIER 4 LAPACK routines (40 test files):

**Matrix Norms (18 files):**
- Dlange, Slange: General matrix norms (1, Inf, Frobenius, Max)
- Dlansy, Slansy: Symmetric matrix norms
- Dlansp, Slansp: Symmetric packed matrix norms
- Dlantr, Slantr: Triangular matrix norms
- Dlantp, Slantp: Triangular packed matrix norms
- Dlangb, Slangb: General banded matrix norms
- Dlansb, Slansb: Symmetric banded matrix norms
- Dlangt, Slangt: General tridiagonal matrix norms
- Dlanst, Slanst: Symmetric tridiagonal matrix norms

**Condition Number Estimation (14 files):**
- Dgecon, Sgecon: General matrix condition (requires dgetrf/sgetrf factorization)
- Dpocon, Spocon: Positive definite condition (requires dpotrf/spotrf)
- Dppcon, Sppcon: Positive definite packed condition (requires dpptrf/spptrf)
- Dpbcon, Spbcon: Positive definite banded condition (requires dpbtrf/spbtrf)
- Dtrcon, Strcon: Triangular matrix condition
- Dgtcon, Sgtcon: Tridiagonal condition (requires dgttrf/sgttrf)
- Dptcon, Sptcon: Positive definite tridiagonal condition (requires dpttrf/spttrf)

**Equilibration (8 files):**
- Dgeequ, Sgeequ: Row/column scaling for general matrices
- Dpoequ, Spoequ: Scaling for symmetric positive definite matrices
- Dgbequ, Sgbequ: Scaling for banded matrices
- Dpbequ, Spbequ: Scaling for banded positive definite matrices

**Utilities (2 files, with known issues):**
- Dlassq, Slassq: Update sum of squares representation (skips NativeLAPACK due to implementation issues)

**Implementation Details:**
- Norm tests use relative epsilon (Math.max(epsilon, |expected| * epsilon)) to handle large values
- Condition tests require prior factorization of matrices
- Equilibration tests compute row/column scaling factors

**Test Results:** 200 tests run, 194 passed, 6 skipped, 0 failures, 0 errors

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
luhenry and others added 2 commits February 14, 2026 18:55
…ions

Implemented comprehensive test coverage for TIER 5 LAPACK routines (16 test files):

**Householder Reflectors (8 files):**
- Dlarf, Slarf: Apply Householder reflector to matrix
- Dlarfb, Slarfb: Apply block reflector (multiple Householder reflectors)
- Dlarft, Slarft: Form triangular factor T of block reflector
- Dlarfx, Slarfx: Apply elementary reflector (optimized for small matrices)

**Givens Rotations (8 files):**
- Dlartv, Slartv: Apply vector of Givens plane rotations
- Dlargv, Slargv: Generate vector of Givens plane rotations
- Dlar1v, Slar1v: Compute one eigenvector using MRRR algorithm (internal routine)
- Dlar2v, Slar2v: Apply vector of rotations to 2 vectors (internal routine)

**Epsilon Tolerance Improvements:**
- Added getMaxValue() helper functions to LAPACKTest for double[] and float[]
- All tests use proper relative epsilon: Math.scalb(epsilon, Math.getExponent(maxValue))
- Fixed 27 test files to use Math.scalb instead of Math.max for cleaner code
- Ensures accurate comparisons regardless of value magnitude

**Implementation Details:**
- Householder tests generate reflectors using dlarfg/slarfg from TIER 2
- Block reflector tests use k=5 reflectors in block form
- Internal MRRR routines (dlar1v, slar1v, dlar2v, slar2v) skip NativeLAPACK
- All TIER 4 norm tests updated to use Math.scalb pattern

**Test Results:** 80 tests run, 68 passed, 12 skipped, 0 failures, 0 errors

These operations are fundamental building blocks for QR factorization, eigenvalue
algorithms (MRRR), and orthogonal matrix transformations throughout LAPACK.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Implemented comprehensive test coverage for TIER 6 LAPACK routines (32 test files):

**LU Factorization (6 files):**
- Dgetrf, Sgetrf: General LU factorization (uses positive definite matrices)
- Dgbtrf, Sgbtrf: Banded LU factorization (diagonal-dominant matrices)
- Dgttrf, Sgttrf: Tridiagonal LU factorization (diagonal-dominant matrices)

**Cholesky Factorization (10 files):**
- Dpotrf, Spotrf: Positive definite Cholesky factorization
- Dpptrf, Spptrf: Packed Cholesky factorization
- Dpbtrf, Spbtrf: Banded Cholesky factorization
- Dpttrf, Spttrf: Tridiagonal Cholesky factorization
- Dsterf, Ssterf: Symmetric tridiagonal eigenvalues (no eigenvectors)

**QR Factorization (8 files):**
- Dgeqrf, Sgeqrf: General QR factorization (blocked)
- Dgeqr2, Sgeqr2: QR factorization (unblocked)
- Dgelqf, Sgelqf: LQ factorization (blocked)
- Dgelq2, Sgelq2: LQ factorization (unblocked)

**QL/RQ Factorization (8 files):**
- Dgeqlf, Sgeqlf: QL factorization (blocked)
- Dgeql2, Sgeql2: QL factorization (unblocked)
- Dgerqf, Sgerqf: RQ factorization (blocked)
- Dgerq2, Sgerq2: RQ factorization (unblocked)

**Implementation Details:**
- LU tests use positive definite matrices to ensure non-singularity
- Banded/tridiagonal tests use diagonal-dominant matrices
- QR/LQ/QL/RQ tests use general matrices (always succeed even for singular)
- Cholesky tests use positive definite matrices (diagonal n+1, off-diagonal 1.0)
- Dsterf/Ssterf use relative epsilon for eigenvalue comparison
- All tests verify INFO=0 (successful completion)

**Test Results:** 160 tests run, 0 failures, 0 errors, 0 skipped

These factorizations are fundamental building blocks for linear solvers, least
squares problems, eigenvalue algorithms, and many other LAPACK operations.

Co-Authored-By: Claude Sonnet 4.5 <[email protected]>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant