Skip to content

Commit

Permalink
Merge branch 'main' of https://github.com/PaulaGarciaMolina/seemps2 i…
Browse files Browse the repository at this point in the history
…nto main
  • Loading branch information
PaulaGarciaMolina committed Jun 21, 2024
2 parents 02b301c + e1d530f commit 7888d66
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion src/seemps/analysis/finite_differences.py
Original file line number Diff line number Diff line change
Expand Up @@ -90,6 +90,7 @@ def smooth_finite_differences_mpo(
dx: float = 1.0,
periodic: bool = False,
base: int = 2,
tol: float = 1e-4,
) -> MPO:
"""Finite differences operator with noise resilience.
Create the operator that implements a finite-difference approximation to
Expand All @@ -111,6 +112,8 @@ def smooth_finite_differences_mpo(
Whether the grid assumes periodic boundary conditions
base : int, default = 2
Quantization of the tensor train (i.e. dimension of the register units)
tol : float, deafult = 1e-4
Tolerance of the step size to avoid rounding errors
Returns
-------
Expand All @@ -128,10 +131,14 @@ def smooth_finite_differences_mpo(
"Unknown finite difference derivative of order {order} with noise filter of size {filter}"
)
else:
i = 1
while dx < tol:
dx = 2 * dx
i *= 2
return mpo_weighted_shifts(
L,
np.asarray(weights) / (dx**order),
shifts,
list(i * np.array(shifts)),
periodic=periodic,
base=base,
)

0 comments on commit 7888d66

Please sign in to comment.