Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 9 additions & 6 deletions pygem/rbf_factory.py
Original file line number Diff line number Diff line change
Expand Up @@ -77,23 +77,26 @@ def inv_multi_quadratic_biharmonic_spline(X, r=1):
return result

@staticmethod
def thin_plate_spline(X, r=1):
def thin_plate_spline(X, r=1, k=2):
"""
It implements the following formula:

.. math::
\\varphi(\\boldsymbol{x}) =
\\left(\\frac{\\boldsymbol{x}}{r}\\right)^2
\\left(\\frac{\\boldsymbol{x}}{r}\\right)^k
\\ln\\frac{\\boldsymbol{x}}{r}

:param numpy.ndarray X: the norm x in the formula above.
:param float r: the parameter r in the formula above.
With k=2 the function is "radius free", that means independent of radius value.

:param numpy.ndarray X: the norm x in the formula above.
:param float r: the parameter r in the formula above.
:param float k: the parameter k in the formula above.

:return: result: the result of the formula above.
:rtype: float
:rtype: float
"""
arg = X / r
result = arg * arg
result = np.power(arg, k)
result = np.where(arg > 0, result * np.log(arg), result)
return result

Expand Down