Skip to content

Commit 30b108d

Browse files
committed
Minimal changes
1 parent 1357d2b commit 30b108d

File tree

3 files changed

+16
-16
lines changed

3 files changed

+16
-16
lines changed

experiments/config.yaml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
dim: 100
2-
density: 0.2
1+
dim: 500
2+
density: 0.1
33
n_processes: 2
44
plot: false

scripts/mpi_running.py

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,12 @@
11
from time import time
22
import numpy as np
33
import scipy
4+
import scipy.sparse as sp
45
from mpi4py import MPI
56
import sys
67
import numpy as np
78
import argparse
8-
from pyclassify.utils import read_config, poisson_2d_structure
9+
from pyclassify.utils import read_config, poisson_2d_structure, make_symmetric
910
from pyclassify.eigenvalues import Lanczos_PRO
1011

1112

@@ -58,27 +59,26 @@ def compute_eigvals(A, n_procs):
5859
density = kwargs["density"]
5960
n_procs = kwargs["n_processes"]
6061

61-
62-
A = poisson_2d_structure(dim)
63-
A_np = A.toarray()
62+
# You could use (for low values of dim, else accuracy suffers):
63+
# A = poisson_2d_structure(dim)
64+
# A_np = A.toarray()
6465

6566
# Alternatively, consider for instance:
66-
# A = sp.random(dim, dim, density=density, format="csr") # uncomment if you want to use a random matrix instead
67-
# or
68-
# eig = np.arange(1, dim + 1)
69-
# A = np.diag(eig)
70-
# U = scipy.stats.ortho_group.rvs(dim)
67+
eig = np.arange(1, dim + 1)
68+
A = np.diag(eig)
69+
U = scipy.stats.ortho_group.rvs(dim)
7170

72-
# A = U @ A @ U.T
73-
# A = make_symmetric(A)
74-
# A_sp = sp.csr_matrix(A)
71+
A = U @ A @ U.T
72+
A = make_symmetric(A)
73+
A_np = A
7574

7675
print("---------------\nCalling Lanczos a first time to compile it...")
7776
Q, diag, off_diag = Lanczos_PRO(A_np, np.ones_like(np.diag(A_np)) * 1.0)
7877
print("Done! Now we compute the eigenvalues.\n---------------")
7978

8079
eigvals, eigvecs, delta_t, total_mem_children = compute_eigvals(A_np, n_procs)
81-
exact_eigvals, exact_eigvecs = np.linalg.eig(A.toarray())
80+
print("Now computing eigenvalues using np")
81+
exact_eigvals, exact_eigvecs = np.linalg.eig(A_np)
8282
print("---------------")
8383
sorted_indices = np.argsort(exact_eigvals)
8484
exact_eigvals = exact_eigvals[sorted_indices]
@@ -87,5 +87,6 @@ def compute_eigvals(A, n_procs):
8787
max_error = np.max(np.abs(exact_eigvals - eigvals))
8888
print(f"The maximum error between real and computed eigenvalues is {max_error}")
8989

90+
9091
if max_error < 1e-8:
9192
print("Pretty small, huh?")

scripts/profiling_memory.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -100,7 +100,6 @@
100100

101101
# Collect the information across all ranks
102102
if rank == 0:
103-
print(f"########################## SIZE = {size} #####################")
104103
total_mem_all = delta_mem_lanczos
105104
print("Eigenvalues computed.")
106105
process = psutil.Process()

0 commit comments

Comments
 (0)