This document lists all the functions that were commented out during the process of enabling strict -Wall -Werror compilation flags. These functions were unused in the codebase but may be useful for future development.
Status Updates:
- ✅ CGS (Conjugate Gradient Squared): Re-enabled with comprehensive tests (see issue/PR for re-enabling CGS)
- ✅ BiCGSTAB (Biconjugate Gradient Stabilized): Re-enabled with comprehensive tests
Lines: 882-889 (commented)
bcgInit :: LinearVectorSpace (SpVector a) =>
MatrixType (SpVector a) -> SpVector a -> SpVector a -> BCG a
bcgInit aa b x0 = BCG x0 r0 r0hat p0 p0hat where
r0 = b ^-^ (aa #> x0)
r0hat = r0
p0 = r0
p0hat = r0Purpose: Initializes the BCG solver state with initial guess and computes initial residuals
Lines: 891-908 (commented)
bcgStep :: (MatrixType (SpVector a) ~ SpMatrix a,
LinearVectorSpace (SpVector a), InnerSpace (SpVector a),
MatrixRing (SpMatrix a), Fractional (Scalar (SpVector a))) =>
SpMatrix a -> BCG a -> BCG a
bcgStep aa (BCG x r rhat p phat) = BCG x1 r1 rhat1 p1 phat1 where
aap = aa #> p
alpha = (r `dot` rhat) / (aap `dot` phat)
x1 = x ^+^ (alpha .* p)
r1 = r ^-^ (alpha .* aap)
rhat1 = rhat ^-^ (alpha .* (transpose aa #> phat))
beta = (r1 `dot` rhat1) / (r `dot` rhat)
p1 = r1 ^+^ (beta .* p)
phat1 = rhat1 ^+^ (beta .* phat)Purpose: Performs one iteration step of the BCG algorithm
Status: Functions have been uncommented, exported from the module, and comprehensive tests added.
Status: ✅ Active (lines 917-920)
cgsInit :: LinearVectorSpace (SpVector a) =>
MatrixType (SpVector a) -> SpVector a -> SpVector a -> CGS a
cgsInit aa b x0 = CGS x0 r0 r0 r0 where
r0 = b ^-^ (aa #> x0) -- residual of initial guess solutionPurpose: Initializes the CGS solver state
Status: ✅ Active (lines 922-933)
cgsStep :: (V (SpVector a), Fractional (Scalar (SpVector a))) =>
MatrixType (SpVector a) -> SpVector a -> CGS a -> CGS a
cgsStep aa rhat (CGS x r p u) = CGS xj1 rj1 pj1 uj1
where
aap = aa #> p
alphaj = (r `dot` rhat) / (aap `dot` rhat)
q = u ^-^ (alphaj .* aap)
xj1 = x ^+^ (alphaj .* (u ^+^ q)) -- updated solution
rj1 = r ^-^ (alphaj .* (aa #> (u ^+^ q))) -- updated residual
betaj = (rj1 `dot` rhat) / (r `dot` rhat)
uj1 = rj1 ^+^ (betaj .* q)
pj1 = uj1 ^+^ (betaj .* (q ^+^ (betaj .* p)))Purpose: Performs one iteration step of the CGS algorithm
Tests Added:
- Unit tests for
cgsInit(verifies initial state) - Unit tests for
cgsStep(verifies iteration works) - Integration tests on 2x2 and 3x3 systems
- Property-based test for SPD (symmetric positive definite) systems
Status: Functions have been uncommented, exported from the module, and comprehensive tests added.
Status: ✅ Active (lines 961-964)
bicgsInit :: LinearVectorSpace (SpVector a) =>
MatrixType (SpVector a) -> SpVector a -> SpVector a -> BICGSTAB a
bicgsInit aa b x0 = BICGSTAB x0 r0 r0 where
r0 = b ^-^ (aa #> x0) -- residual of initial guess solutionPurpose: Initializes the BiCGSTAB solver state
Status: ✅ Active (lines 966-977)
bicgstabStep :: (V (SpVector a), Fractional (Scalar (SpVector a))) =>
MatrixType (SpVector a) -> SpVector a -> BICGSTAB a -> BICGSTAB a
bicgstabStep aa r0hat (BICGSTAB x r p) = BICGSTAB xj1 rj1 pj1 where
aap = aa #> p
alphaj = (r <.> r0hat) / (aap <.> r0hat)
sj = r ^-^ (alphaj .* aap)
aasj = aa #> sj
omegaj = (aasj <.> sj) / (aasj <.> aasj)
xj1 = x ^+^ (alphaj .* p) ^+^ (omegaj .* sj) -- updated solution
rj1 = sj ^-^ (omegaj .* aasj)
betaj = (rj1 <.> r0hat)/(r <.> r0hat) * alphaj / omegaj
pj1 = rj1 ^+^ (betaj .* (p ^-^ (omegaj .* aap)))Purpose: Performs one iteration step of the BiCGSTAB algorithm
Tests Added:
- Unit tests for
bicgsInit(verifies initial state) - Unit tests for
bicgstabStep(verifies iteration works) - Integration tests on 2x2 and 3x3 systems
- Property-based test for SPD (symmetric positive definite) systems
Lines: 980-985 (commented)
pinv :: (LinearSystem v, MatrixRing (MatrixType v), MonadThrow m, MonadIO m) =>
MatrixType v -> v -> m v
pinv aa b = (aa #^# aa) <\> atb where
atb = transpose aa #> bPurpose: Computes least-squares approximation of a rectangular system using Moore-Penrose pseudoinverse Note: This function was also removed from the module export list (line 20)
Lines: 1027-1030 (commented)
class IterativeSolver s where
-- solver :: Purpose: Placeholder typeclass for iterative solver abstraction (was incomplete)
- Total functions originally commented out: 10
- Re-enabled: 4 (CGS + BiCGSTAB)
- Still commented out: 6
- BCG-related: 2 functions
- Pseudoinverse: 1 function
- Typeclass: 1 class definition
- Show instances: 1 instance (for BCG)
All these functions were commented out because they triggered the -Wunused-top-binds warning under -Wall -Werror compilation. While these are sophisticated iterative solver implementations that could be valuable for solving sparse linear systems, they were not currently used anywhere in the codebase.
To re-enable these functions in the future:
- Export them from the module - Add them to the export list in the module header
- Use them in examples or tests - Create usage examples demonstrating their functionality
- Document them properly - Add comprehensive Haddock documentation
- Add to the public API - If they're meant to be part of the public API, ensure they're properly exposed
The following data types remain active and are used by the commented-out functions:
data BCG a = BCG { _xBcg, _rBcg, _rHatBcg, _pBcg, _pHatBcg :: SpVector a }data CGS a = CGS { _x, _r, _p, _u :: SpVector a}data BICGSTAB a = BICGSTAB { _xBicgstab, _rBicgstab, _pBicgstab :: SpVector a}
These data types could be commented out as well if they're truly unused, but they've been retained in case they're referenced elsewhere or needed for the future implementation of these solvers.