Skip to content

Commit

Permalink
Merge pull request #138 from wagnertheresa/develop
Browse files Browse the repository at this point in the history
added kernel der_laplacian_rbf
  • Loading branch information
passscoed authored Apr 16, 2024
2 parents d1238a7 + 5098ca9 commit 8bec1ef
Show file tree
Hide file tree
Showing 9 changed files with 28 additions and 0 deletions.
1 change: 1 addition & 0 deletions applications/fastsum/fastsum.m
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
% 'cot' K(x) = cot(cx)
% 'one_over_cube' K(x) = 1/x^3
% 'laplacian_rbf' K(x) = EXP(-|x|/c)
% 'der_laplacian_rbf' K(x) = |x|/c EXP(-|x|/c)
% 'xx_gaussian' K(x) = x^2/c^2 EXP(-x^2/c^2)
% 'absx' K(x) = |x|
%
Expand Down
2 changes: 2 additions & 0 deletions applications/fastsum/fastsum_matlab.c
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,8 @@ int main(int argc, char **argv)
kernel = log_sin;
else if (strcmp(s, "laplacian_rbf") == 0)
kernel = laplacian_rbf;
else if (strcmp(s, "der_laplacian_rbf") == 0)
kernel = der_laplacian_rbf;
else if (strcmp(s, "xx_gaussian") == 0)
kernel = xx_gaussian;
else if (strcmp(s, "absx") == 0)
Expand Down
2 changes: 2 additions & 0 deletions applications/fastsum/fastsum_test.c
Original file line number Diff line number Diff line change
Expand Up @@ -124,6 +124,8 @@ int main(int argc, char **argv)
kernel = log_sin;
else if (strcmp(s, "laplacian_rbf") == 0)
kernel = laplacian_rbf;
else if (strcmp(s, "der_laplacian_rbf") == 0)
kernel = der_laplacian_rbf;
else if (strcmp(s, "xx_gaussian") == 0)
kernel = xx_gaussian;
else if (strcmp(s, "absx") == 0)
Expand Down
16 changes: 16 additions & 0 deletions applications/fastsum/kernels.c
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,22 @@ C laplacian_rbf(R x, int der, const R *param) /* K(x)=EXP(-|x|/c) */
return value;
}

C der_laplacian_rbf(R x, int der, const R *param) /* K(x)=|x|/c EXP(-|x|/c) */
{
R c = param[0];
R value = K(0.0);

switch (der)
{
case 0 : value = (FABS(x)/c)*EXP(-FABS(x)/c); break;
default:
value = (POW(K(-1.0),(R)der))*((FABS(x)-(R)der*c)/POW(c,(R)der+1))*EXP(-FABS(x)/c);
value *= 1 - 2 * ((x < K(0.0)) && (der % 2));
}

return value;
}

C xx_gaussian(R x, int der, const R *param) /* K(x)=x^2/c^2 EXP(-x^2/c^2) */
{
R c = param[0];
Expand Down
1 change: 1 addition & 0 deletions applications/fastsum/kernels.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,7 @@ C kcot(R x, int der, const R *param); /**< K(x) = cot(cx) */
C one_over_cube(R x, int der, const R *param); /**< K(x) = 1/x^3 */
C log_sin(R x, int der, const R *param); /**< K(x) = log(|sin(cx)|) */
C laplacian_rbf(R x, int der, const R *param); /**< K(x) = exp(-|x|/c) */
C der_laplacian_rbf(R x, int der, const R *param); /**< K(x) = |x|/c exp(-|x|/c) */
C xx_gaussian(R x, int der, const R *param); /**< K(x) = x^2/c^2 exp(-x^2/c^2) */
C absx(R x, int der, const R *param); /**< K(x) = |x| */
/* \} */
Expand Down
2 changes: 2 additions & 0 deletions julia/fastsum/libfastsumjulia.c
Original file line number Diff line number Diff line change
Expand Up @@ -55,6 +55,8 @@ int jfastsum_init( fastsum_plan* p, int d, char* s, double* c, unsigned int f, i
kernel = log_sin;
else if ( strcmp(s, "laplacian_rbf") == 0 )
kernel = laplacian_rbf;
else if ( strcmp(s, "der_laplacian_rbf") == 0 )
kernel = der_laplacian_rbf;
else if ( strcmp(s, "xx_gaussian") == 0 )
kernel = xx_gaussian;
else if ( strcmp(s, "absx") == 0 )
Expand Down
2 changes: 2 additions & 0 deletions matlab/fastsum/fastsummex.c
Original file line number Diff line number Diff line change
Expand Up @@ -134,6 +134,8 @@ static kernel get_kernel(const mxArray *p)
ker = log_sin;
else if (strcmp(s, "laplacian_rbf") == 0)
ker = laplacian_rbf;
else if (strcmp(s, "der_laplacian_rbf") == 0)
ker = der_laplacian_rbf;
else if (strcmp(s, "xx_gaussian") == 0)
ker = xx_gaussian;
else if (strcmp(s, "absx") == 0)
Expand Down
1 change: 1 addition & 0 deletions matlab/fastsum/simple_test.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
% 'one_over_cube' K(x) = 1/x^3
% 'log_sin' K(x) = LOG(|SIN(cx)|)
% 'laplacian_rbf' K(x) = EXP(-|x|/c)
% 'der_laplacian_rbf' K(x) = |x|/c EXP(-|x|/c)
% 'xx_gaussian' K(x) = x^2/c^2 EXP(-x^2/c^2)
% 'absx' K(x) = |x|

Expand Down
1 change: 1 addition & 0 deletions matlab/fastsum/test_fastsum.m
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@
% 'one_over_cube' K(x) = 1/x^3
% 'log_sin' K(x) = LOG(|SIN(cx)|)
% 'laplacian_rbf' K(x) = EXP(-|x|/c)
% 'der_laplacian_rbf' K(x) = |x|/c EXP(-|x|/c)
% 'xx_gaussian' K(x) = x^2/c^2 EXP(-x^2/c^2)
% 'absx' K(x) = |x|

Expand Down

0 comments on commit 8bec1ef

Please sign in to comment.