Skip to content

Commit 48c2bdb

Browse files
authored
Merge pull request #231 from giadadalla/TPS_extension
Tps extension
2 parents 33ecc2f + 57d5097 commit 48c2bdb

File tree

1 file changed

+9
-6
lines changed

1 file changed

+9
-6
lines changed

pygem/rbf_factory.py

Lines changed: 9 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -77,23 +77,26 @@ def inv_multi_quadratic_biharmonic_spline(X, r=1):
7777
return result
7878

7979
@staticmethod
80-
def thin_plate_spline(X, r=1):
80+
def thin_plate_spline(X, r=1, k=2):
8181
"""
8282
It implements the following formula:
8383
8484
.. math::
8585
\\varphi(\\boldsymbol{x}) =
86-
\\left(\\frac{\\boldsymbol{x}}{r}\\right)^2
86+
\\left(\\frac{\\boldsymbol{x}}{r}\\right)^k
8787
\\ln\\frac{\\boldsymbol{x}}{r}
8888
89-
:param numpy.ndarray X: the norm x in the formula above.
90-
:param float r: the parameter r in the formula above.
89+
With k=2 the function is "radius free", that means independent of radius value.
9190
91+
:param numpy.ndarray X: the norm x in the formula above.
92+
:param float r: the parameter r in the formula above.
93+
:param float k: the parameter k in the formula above.
94+
9295
:return: result: the result of the formula above.
93-
:rtype: float
96+
:rtype: float
9497
"""
9598
arg = X / r
96-
result = arg * arg
99+
result = np.power(arg, k)
97100
result = np.where(arg > 0, result * np.log(arg), result)
98101
return result
99102

0 commit comments

Comments
 (0)