Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added kernel der_laplacian_rbf #138

Merged
merged 4 commits into from
Apr 16, 2024
Merged
Show file tree
Hide file tree
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
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
Loading