executable-engineering 0.1.34__py3-none-any.whl → 0.1.36__py3-none-any.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- executable_engineering/__init__.py +7 -1
- executable_engineering/linearsystems_module.py +33 -2
- {executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/METADATA +1 -1
- {executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/RECORD +7 -7
- {executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/WHEEL +0 -0
- {executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/licenses/LICENSE +0 -0
- {executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/top_level.txt +0 -0
|
@@ -13,7 +13,13 @@ __all__ = [
|
|
|
13
13
|
"visualize_matrix_norms",
|
|
14
14
|
"jacobi_step",
|
|
15
15
|
"gauss_seidel_step",
|
|
16
|
-
"sor_step
|
|
16
|
+
"sor_step",
|
|
17
|
+
"visualize_convergence_2d",
|
|
18
|
+
"create_diagonally_dominant_matrix",
|
|
19
|
+
"iter_solve",
|
|
20
|
+
"steepest_descent",
|
|
21
|
+
"conjugate_gradient",
|
|
22
|
+
"IterationTracker",
|
|
17
23
|
"init_weights",
|
|
18
24
|
"tanh",
|
|
19
25
|
"tanh_derivative",
|
|
@@ -430,13 +430,44 @@ class IterationTracker:
|
|
|
430
430
|
"""
|
|
431
431
|
A clean callback tracker for native SciPy solvers (cg, gmres, etc.).
|
|
432
432
|
"""
|
|
433
|
-
def __init__(self, x0=None):
|
|
433
|
+
def __init__(self, x0=None, A=None, b=None, print_residual=False):
|
|
434
434
|
import numpy as np
|
|
435
435
|
if x0 is not None:
|
|
436
436
|
self.iterations = [np.array(x0).copy()]
|
|
437
437
|
else:
|
|
438
438
|
self.iterations = []
|
|
439
|
+
|
|
440
|
+
self.residuals = []
|
|
441
|
+
self.A = A
|
|
442
|
+
self.b = b
|
|
443
|
+
self.print_residual = print_residual
|
|
444
|
+
self.step = 0
|
|
445
|
+
|
|
446
|
+
if A is not None and b is not None and x0 is not None:
|
|
447
|
+
x_arr = np.array(x0)
|
|
448
|
+
res = np.linalg.norm(A @ x_arr - b)
|
|
449
|
+
self.residuals.append(res)
|
|
450
|
+
if self.print_residual:
|
|
451
|
+
guess_str = np.array2string(x_arr, precision=4, separator=', ', suppress_small=True)
|
|
452
|
+
print(f"Step {self.step}: Guess = {guess_str}, Residual = {res:.4e}")
|
|
439
453
|
|
|
440
454
|
def __call__(self, xk):
|
|
441
455
|
import numpy as np
|
|
442
|
-
self.
|
|
456
|
+
self.step += 1
|
|
457
|
+
|
|
458
|
+
# Check if xk is a scalar (i.e. callback_type='pr_norm' in GMRES)
|
|
459
|
+
if np.isscalar(xk) or (isinstance(xk, np.ndarray) and xk.size == 1):
|
|
460
|
+
res = float(np.squeeze(xk))
|
|
461
|
+
self.residuals.append(res)
|
|
462
|
+
if self.print_residual:
|
|
463
|
+
print(f"Step {self.step}: Residual = {res:.4e} (Guess vector xk not computed by SciPy GMRES)")
|
|
464
|
+
else:
|
|
465
|
+
# xk is a vector (i.e. from CG)
|
|
466
|
+
x = np.array(xk).copy()
|
|
467
|
+
self.iterations.append(x)
|
|
468
|
+
if self.A is not None and self.b is not None:
|
|
469
|
+
res = np.linalg.norm(self.A @ x - self.b)
|
|
470
|
+
self.residuals.append(res)
|
|
471
|
+
if self.print_residual:
|
|
472
|
+
guess_str = np.array2string(x, precision=4, separator=', ', suppress_small=True)
|
|
473
|
+
print(f"Step {self.step}: Guess = {guess_str}, Residual = {res:.4e}")
|
{executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/METADATA
RENAMED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.4
|
|
2
2
|
Name: executable_engineering
|
|
3
|
-
Version: 0.1.
|
|
3
|
+
Version: 0.1.36
|
|
4
4
|
Summary: Demonstrative tools for the Executable Engineering textbook
|
|
5
5
|
Home-page: https://github.com/themintlab/ExecutableEngineering/tree/main/executable_engineering
|
|
6
6
|
Author: Michael Welland
|
|
@@ -1,14 +1,14 @@
|
|
|
1
|
-
executable_engineering/__init__.py,sha256=
|
|
1
|
+
executable_engineering/__init__.py,sha256=GiYYijxAfiee44SRLXjMsFCa3xOPWtUx0tnlWm4G6TM,1596
|
|
2
2
|
executable_engineering/closedoptimization_module.py,sha256=i9KkdulyCZmriYKlx0CuUetjoMmxJm9ADWgStU3w85w,9273
|
|
3
3
|
executable_engineering/closedrootfinder_module.py,sha256=ozccVABOrTiqcdkkqwAWRNo04MsDC0Z_f_tfukl3q20,5706
|
|
4
4
|
executable_engineering/gradientoptimization_module.py,sha256=-2fErE9cemSEPeV9PlWOf4cF7Tr6DjilEw_NxvE-JYw,6601
|
|
5
|
-
executable_engineering/linearsystems_module.py,sha256=
|
|
5
|
+
executable_engineering/linearsystems_module.py,sha256=cFP8_q9_aBBekx-JtemDVgkUAqR8DIYSnljLYYkYe4c,16579
|
|
6
6
|
executable_engineering/neuralnet_module.py,sha256=Hu9QFoMyODg4RCEpHmT9zTwzjcVFYM8ZLYtbB3CbrsA,10102
|
|
7
7
|
executable_engineering/numerical_error_module.py,sha256=wxfYP8u29c19I2D6MxpQV3zDMV0DpS1QUqFpp3f6eGE,1204
|
|
8
8
|
executable_engineering/openoptimization_module.py,sha256=OCPyrynkTo1It50RoT7irnL72aQn6FexE_R1SfFYxlg,8590
|
|
9
9
|
executable_engineering/openrootfinder_module.py,sha256=rmXDi0XdrDYdLZdPFgYCihMg_4NF1D71i6kh8Kx-V2w,5802
|
|
10
|
-
executable_engineering-0.1.
|
|
11
|
-
executable_engineering-0.1.
|
|
12
|
-
executable_engineering-0.1.
|
|
13
|
-
executable_engineering-0.1.
|
|
14
|
-
executable_engineering-0.1.
|
|
10
|
+
executable_engineering-0.1.36.dist-info/licenses/LICENSE,sha256=Tg4nrt8rFhgpkPbIA8SWoCR3MlGLw0NufB8AE6-TH_o,1074
|
|
11
|
+
executable_engineering-0.1.36.dist-info/METADATA,sha256=NLcOtA7ZxkdcBez1vQWAWA0p8nM01yux2n-nIq6CwWA,1648
|
|
12
|
+
executable_engineering-0.1.36.dist-info/WHEEL,sha256=YVMoNqKzERt-wjUZwJ33xBGAwnFl-4cqbYkTtWa4itE,91
|
|
13
|
+
executable_engineering-0.1.36.dist-info/top_level.txt,sha256=0U5ATV5WGTLvN9rRSjQ54TyL-ztTyXaN3FzZ_QMq4HM,23
|
|
14
|
+
executable_engineering-0.1.36.dist-info/RECORD,,
|
|
File without changes
|
{executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/licenses/LICENSE
RENAMED
|
File without changes
|
{executable_engineering-0.1.34.dist-info → executable_engineering-0.1.36.dist-info}/top_level.txt
RENAMED
|
File without changes
|