From 4602b36e9d5ea08656e3222846a1f161bbb1cec1 Mon Sep 17 00:00:00 2001 From: y-jan137 Date: Mon, 27 Apr 2026 07:24:41 +0300 Subject: Module refactor --- experiments/hilbert_qr.cpp | 30 +++++++----------------------- 1 file changed, 7 insertions(+), 23 deletions(-) (limited to 'experiments/hilbert_qr.cpp') diff --git a/experiments/hilbert_qr.cpp b/experiments/hilbert_qr.cpp index 849bc8d..3a52194 100644 --- a/experiments/hilbert_qr.cpp +++ b/experiments/hilbert_qr.cpp @@ -1,20 +1,8 @@ -#include "matrix.hpp" -#include "qr.hpp" +import linalgebra; +import std; -#include -#include -#include -#include -#include -#include -#include -#include -#include - -using linalg::Matrix; -using linalg::QRResult; - -// --- Matrix construction --- +using linalgebra::Matrix; +using linalgebra::QRResult; Matrix hilbert(std::size_t n) { Matrix H(n, n); @@ -24,8 +12,6 @@ Matrix hilbert(std::size_t n) { return H; } -// --- Metrics --- - double reconstruction_error(const Matrix& A, const QRResult& qr) { const std::size_t m = A.rows(); const std::size_t n = A.cols(); @@ -53,7 +39,6 @@ double orthogonality_error(const QRResult& qr) { return std::sqrt(err); } - using Clock = std::chrono::high_resolution_clock; using Seconds = std::chrono::duration; @@ -98,7 +83,6 @@ void print_row(const std::string& method, std::optional r) { << std::setw(10) << r->time_s * 1e6 << " µs\n"; } - int main() { std::cout << std::string(70, '*') << "\n"; std::cout << " Hilbert QR Experiment: comparing GS variants and Householder\n"; @@ -124,11 +108,11 @@ int main() { std::cout << std::string(70, ' ') << "\n"; print_row("classical_gs", - measure(H, [](const Matrix& A) { return linalg::qr_classical_gs(A); })); + measure(H, [](const Matrix& A) { return linalgebra::qr_classical_gs(A); })); print_row("modified_gs", - measure(H, [](const Matrix& A) { return linalg::qr_modified_gs(A); })); + measure(H, [](const Matrix& A) { return linalgebra::qr_modified_gs(A); })); print_row("householder", - measure(H, [](const Matrix& A) { return linalg::qr_householder(A); })); + measure(H, [](const Matrix& A) { return linalgebra::qr_householder(A); })); } return 0; -- cgit v1.2.3