mirror of
https://github.com/fjosw/pyerrors.git
synced 2025-05-15 12:03:42 +02:00
feat: backward derivative implemented, additional tests for deriv
This commit is contained in:
parent
8165479846
commit
a729def937
2 changed files with 25 additions and 1 deletions
|
@ -467,7 +467,7 @@ class Corr:
|
|||
----------
|
||||
variant : str
|
||||
decides which definition of the finite differences derivative is used.
|
||||
Available choice: symmetric, forward, improved, default: symmetric
|
||||
Available choice: symmetric, forward, backward, improved, default: symmetric
|
||||
"""
|
||||
if variant == "symmetric":
|
||||
newcontent = []
|
||||
|
@ -489,6 +489,16 @@ class Corr:
|
|||
if(all([x is None for x in newcontent])):
|
||||
raise Exception("Derivative is undefined at all timeslices")
|
||||
return Corr(newcontent, padding=[0, 1])
|
||||
elif variant == "backward":
|
||||
newcontent = []
|
||||
for t in range(1, self.T):
|
||||
if (self.content[t - 1] is None) or (self.content[t] is None):
|
||||
newcontent.append(None)
|
||||
else:
|
||||
newcontent.append(self.content[t] - self.content[t - 1])
|
||||
if(all([x is None for x in newcontent])):
|
||||
raise Exception("Derivative is undefined at all timeslices")
|
||||
return Corr(newcontent, padding=[1, 0])
|
||||
elif variant == "improved":
|
||||
newcontent = []
|
||||
for t in range(2, self.T - 2):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue