From 8666acd6c33c3d408328d9f548175029fb1b5bd2 Mon Sep 17 00:00:00 2001 From: Jaron Kent-Dobias Date: Mon, 10 Feb 2025 19:04:48 -0300 Subject: Modfied code to produce chain of examples --- fits.cpp | 24 +++++++++++------------- 1 file changed, 11 insertions(+), 13 deletions(-) diff --git a/fits.cpp b/fits.cpp index 7ee9c64..9696e16 100644 --- a/fits.cpp +++ b/fits.cpp @@ -125,7 +125,6 @@ Data generateData(Real(*f)(Real), unsigned M, Real σ, Rng& r) { } int main(int argc, char* argv[]) { - unsigned N = 10; unsigned M = 10; unsigned nBatches = 5; Real σ = 0.2; @@ -134,11 +133,8 @@ int main(int argc, char* argv[]) { int opt; - while ((opt = getopt(argc, argv, "N:M:s:S:B:i:")) != -1) { + while ((opt = getopt(argc, argv, "M:s:S:B:i:")) != -1) { switch (opt) { - case 'N': - N = (unsigned)atof(optarg); - break; case 'M': M = (unsigned)atof(optarg); break; @@ -170,17 +166,19 @@ int main(int argc, char* argv[]) { } std::cout << std::endl; - Vector a₀ = Vector::Zero(N); - for (Real& aa : a₀) { - aa = r.variate(0, iniVar); - } + for (unsigned N = 1; N <= 2 * M; N++) { + Vector a₀ = Vector::Zero(N); + for (Real& aa : a₀) { + aa = r.variate(0, iniVar); + } - Vector a = stochasticGradientDescent(data, a₀, nBatches, maxSteps); + Vector a = stochasticGradientDescent(data, a₀, nBatches, maxSteps); - for (unsigned i = 0; i < N; i++) { - std::cout << a[i] << " "; + for (Real ai : a) { + std::cout << ai << " "; + } + std::cout << std::endl; } - std::cout << std::endl; return 0; } -- cgit v1.2.3-70-g09d2