From eb2d82115a3768dabc2b8996eeb715186031fa2a Mon Sep 17 00:00:00 2001 From: alberto Date: Sun, 12 Apr 2026 15:50:34 +0200 Subject: [PATCH] Refactor and add test 2. --- report/main.tex | 81 ++++++++++++++++++++++++---- report/ref.bib | 9 ++++ report/references.bib | 0 src/afgl/example_2.py | 13 ----- src/afgl/main.py | 11 ++-- src/afgl/{example_1.py => test_1.py} | 4 +- src/afgl/test_2.py | 36 +++++++++++++ 7 files changed, 120 insertions(+), 34 deletions(-) create mode 100644 report/ref.bib delete mode 100644 report/references.bib delete mode 100644 src/afgl/example_2.py rename src/afgl/{example_1.py => test_1.py} (100%) create mode 100644 src/afgl/test_2.py diff --git a/report/main.tex b/report/main.tex index fd07c7d..a67a1f9 100644 --- a/report/main.tex +++ b/report/main.tex @@ -1,25 +1,79 @@ -% !TeX program = pdflatex -\documentclass{mathreport} % Uses our custom mathreport.cls +\documentclass[11pt]{article} +\usepackage[margin=1.2in]{geometry} +\usepackage[utf8]{inputenc} +\usepackage[T1]{fontenc} +\usepackage[english]{babel} +\usepackage{fourier} +\usepackage{amsthm} +\usepackage{amssymb} +\usepackage{amsmath} +\usepackage{amsfonts} +\usepackage{latexsym} +\usepackage{graphicx} +\usepackage{float} +\usepackage{etoolbox} +\usepackage{hyperref} +\usepackage{tikz} +\usepackage{lipsum} +\usepackage{algorithm} +\usepackage{algpseudocode} +\usepackage{mathtools} +\usepackage{nccmath} +\usepackage[most]{tcolorbox} +\newtcolorbox[auto counter]{problem}[1][]{% + enhanced, + breakable, + colback=white, + colbacktitle=white, + coltitle=black, + fonttitle=\bfseries, + boxrule=.6pt, + titlerule=.2pt, + toptitle=3pt, + bottomtitle=3pt, + title=GitHub repository of this project} + +\RequirePackage[activate={true,nocompatibility},final,tracking=true,kerning=true,spacing=true]{microtype} +\SetTracking{encoding={*}, shape=sc}{40} % Spacing for Small Caps + + +\newcommand{\R}{\mathbb{R}} +\newcommand{\N}{\mathbb{N}} +\newcommand{\Z}{\mathbb{Z}} +\newcommand{\Q}{\mathbb{Q}} +\newcommand{\C}{\mathbb{C}} + +\newtheorem{theorem}{Theorem}[section] +\newtheorem{lemma}[theorem]{Lemma} +\newtheorem{proposition}[theorem]{Proposition} +\newtheorem{corollary}[theorem]{Corollary} +\theoremstyle{definition} +\newtheorem{definition}[theorem]{Definition} +\newtheorem{example}[theorem]{Example} +\theoremstyle{remark} +\newtheorem{remark}[theorem]{Remark} -% Load bibliography -\addbibresource{references.bib} - -% --- Document Metadata --- \title{% Accelerated filtering on graphs using Lanczos method \\ \large Relazione del progetto di Calcolo Scientifico} \author{Alberto Defendi} -\date{\small\today} -\begin{document} +\date{} +\setlength{\parskip}{1em} +\setlength{\parindent}{0em} + +\begin{document} \maketitle \begin{abstract} - \noindent \small \textbf{\textit{Abstract.}} + \noindent The Lanczos algorithm \ldots \end{abstract} -\section{Introduction} +{\setlength{\parskip}{0em} +\tableofcontents} + +\section{Introduzione} Introduciamo alcuni concetti di teoria dei grafi e alcuni risultati del corso che verranno usati nel corso della sperimentazione. Scopo del progetto รจ verificare numericamente i risultati @@ -38,6 +92,11 @@ attraverso la valutazione $g(\mathcal{L})s$. test -\printbibliography +\clearpage +\bibliographystyle{unsrt} +\bibliography{ref} +\nocite{*} + + \end{document} diff --git a/report/ref.bib b/report/ref.bib new file mode 100644 index 0000000..6400e31 --- /dev/null +++ b/report/ref.bib @@ -0,0 +1,9 @@ +@article{susnjara2015, + title={Accelerated filtering on graphs using Lanczos method}, + author={Ana Susnjara and Nathanael Perraudin and Daniel Kressner and Pierre Vandergheynst}, + year={2015}, + eprint={1509.04537}, + archivePrefix={arXiv}, + primaryClass={math.NA}, + url={https://arxiv.org/abs/1509.04537}, +} diff --git a/report/references.bib b/report/references.bib deleted file mode 100644 index e69de29..0000000 diff --git a/src/afgl/example_2.py b/src/afgl/example_2.py deleted file mode 100644 index 7ba58d3..0000000 --- a/src/afgl/example_2.py +++ /dev/null @@ -1,13 +0,0 @@ -def run() -> None: - """Genera i grafi di di Erdos-Reny di grandezza crescente (ad esempio 250, - 500,1000, 2000, 4000) e parametro p = 0.04 e misura il tempo - computazionale del metodo di Lanczos utilizzando come soglia per il criterio - d'arresto epsilon = 10^-2 (o una soglia a scelta). - - Args: - None - - Returns: - None - """ - pass diff --git a/src/afgl/main.py b/src/afgl/main.py index 57e613a..b4076e0 100644 --- a/src/afgl/main.py +++ b/src/afgl/main.py @@ -1,18 +1,13 @@ import sys -import scienceplots # noqa: F401 - -# Requires latex installed -import afgl.example_1 as ex1 -import afgl.example_2 as ex2 +import afgl.test_2 as t_2 from afgl.util.plot import plot_setup def run() -> None: plot_setup() - # example_1() - ex1.run() - ex2.run() + # t_1.run() + t_2.run() if __name__ == "__main__": diff --git a/src/afgl/example_1.py b/src/afgl/test_1.py similarity index 100% rename from src/afgl/example_1.py rename to src/afgl/test_1.py index c5baa04..8ba988d 100644 --- a/src/afgl/example_1.py +++ b/src/afgl/test_1.py @@ -2,10 +2,10 @@ import matplotlib.pyplot as plt import matplotlib.ticker as ticker import numpy as np import numpy.linalg as LA -import scienceplots # noqa: F401 -import scipy # Requires latex installed +import scienceplots # noqa: F401 +import scipy from pygsp import graphs from afgl.util.build_T_matrix import build_T_matrix diff --git a/src/afgl/test_2.py b/src/afgl/test_2.py new file mode 100644 index 0000000..e3fccd7 --- /dev/null +++ b/src/afgl/test_2.py @@ -0,0 +1,36 @@ +import numpy as np +import numpy.linalg as LA +from pygsp import graphs + +from afgl.util.lanczos import lanczos + + +def run() -> None: + """Genera i grafi di di Erdos-Reny di grandezza crescente (ad esempio 250, + 500,1000, 2000, 4000) e parametro p = 0.04 e misura il tempo + computazionale del metodo di Lanczos utilizzando come soglia per il criterio + d'arresto epsilon = 10^-2 (o una soglia a scelta). + + Args: + None + + Returns: + None + """ + n = 6 + p = 0.04 + + M = 200 + + N_VALUES = 250 * (2 ** np.arange(n)) + + for N in N_VALUES: + s = np.random.randint(1, 10000, N).astype(float) + # Normalize s as in request + s /= LA.norm(s) + + G = graphs.ErdosRenyi(N, p) + G.compute_laplacian("combinatorial") + L = G.L + + lanczos(L, s, M)