using Krylov, HarwellRutherfordBoeing, SuiteSparseMatrixCollection
using LinearAlgebra, Printf

ssmc = ssmc_db(verbose=false)
matrix = ssmc_matrices(ssmc, "HB", "gemat1")
path = fetch_ssmc(matrix, format="RB")

A = RutherfordBoeingData(joinpath(path[1], "$([1]).rb")).data
(m, n) = size(A)
@printf("System size: %d rows and %d columns\n", m, n)

x_exact = A' * ones(m)
x_exact_norm = norm(x_exact)
x_exact /= x_exact_norm
b = A * x_exact
(x, stats) = crmr(A, b)
resid = norm(A * x - b) / norm(b)
@printf("CRMR: Relative residual: %7.1e\n", resid)
@printf("CRMR: ‖x - x*‖₂: %7.1e\n", norm(x - x_exact))
 Downloading artifact: HB/gemat1.RB
 Downloading artifact: HB/gemat11.RB
 Downloading artifact: HB/gemat12.RB
System size: 4929 rows and 10595 columns
 niter: 7
 solved: false
 inconsistent: true
 residuals: []
 Aresiduals: []
 κ₂(A): []
 timer: 960.18μs
 status: system probably inconsistent but least squares/norm solution found
CRMR: Relative residual: 4.0e-06
CRMR: ‖x - x*‖₂: 6.3e-03