Change scaling plot to loglog

This commit is contained in:
2025-09-18 09:12:22 +02:00
parent fededb4ed3
commit 48e8c6ee64
3 changed files with 5 additions and 4 deletions
Binary file not shown.
+1 -2
View File
@@ -150,8 +150,7 @@ The Jacobi rotation algorithm is implemented as described in the lecture notes.
\section*{Problem 5}
\subsection*{Subproblem (a)}
The scaling of the number of iterations is tested in \texttt{src/project2/scaling\_tester.cpp}. The results are shown in \autoref{fig:scaling}. On the logarithmic scale, we see a trend that is roughly of the order $\sqrt{\log N}$.
The scaling of the number of iterations is tested in \texttt{src/project2/scaling\_tester.cpp}. The results are shown in \autoref{fig:scaling}. On the double logarithmic scale, the scaling is approximately linear, indicating a polynomial relation between the number of iterations and the matrix size $N$.
\begin{figure}
\centering
\includegraphics[width=0.7\textwidth]{include/scaling_data_iterations.pdf}
+4 -2
View File
@@ -7,6 +7,7 @@ import os
parser = argparse.ArgumentParser(description='Plot scaling data.')
parser.add_argument('input_file', type=str, help='Path to the input CSV file')
parser.add_argument("--times", "-t", action="store_true", help="Plot times instead of iterations")
parser.add_argument("--no-loglog", "-nL", action="store_true", help="Do not use log-log scale")
args = parser.parse_args()
data = pd.read_csv(args.input_file)
@@ -18,16 +19,17 @@ if args.times:
ax.plot(x, data["Arma_time"], label='Armadillo Time', color='C1', linestyle='-', marker='o')
ax.set_ylabel('Time (s)')
ax.set_title('Scaling of Computation Time')
ax.set_yscale('log')
ax.legend()
ax.grid()
else:
ax.set_ylabel('Number of Iterations')
ax.set_title('Scaling of Jacobi Iterations')
ax.set_yscale('log')
ax.plot(x, data["Jacobi_iterations"], label='Jacobi Iterations', color='C0', linestyle='-', marker='o')
ax.grid()
if not args.no_loglog:
ax.set_xscale('log')
ax.set_yscale('log')
ax.set_xlabel('Matrix Size N')
dir = os.path.abspath(os.path.join(os.path.dirname(__file__), "../../../projects/project2/include"))
filename = args.input_file.split("/")[-1].replace(".txt", "")