Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
F
fluidity
Project overview
Project overview
Details
Activity
Releases
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Issues
0
Issues
0
List
Boards
Labels
Service Desk
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Operations
Operations
Incidents
Environments
Packages & Registries
Packages & Registries
Container Registry
Analytics
Analytics
CI / CD
Repository
Value Stream
Wiki
Wiki
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
mavt-cse
fluidity
Commits
750b00f8
Commit
750b00f8
authored
Jun 01, 2017
by
Sergey Litvinov
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Derive cubic spline kernel
parent
bcc9d3ae
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
69 additions
and
3 deletions
+69
-3
poc/del.m
poc/del.m
+36
-3
poc/ker/cubic.mac
poc/ker/cubic.mac
+33
-0
No files found.
poc/del.m
View file @
750b00f8
n = 20;
global L
global n x y
global rc
rc = 0.2;
L = 1;
n = 10;
x = rand(n, 1);
y = rand(n, 1);
T = delaunay(x, y);
triplot(T, x, y);
function w = wk(r)
global rc
A = 1;
r /= rc; r *= 2;
if r
<
1;
w =
1
-
3/2
*r
^2
endfunction
function
r =
wrap(r,
r0
)
global
L
dr =
r
-
r0
;
if
abs
(
dr
-
L
)
<
abs
(
dr
);
r
-=
L;
elseif
abs
(
dr
+
L
)
<
abs
(
dr
);
r
+=
L
;
endif
endfunction
function
r =
dist(i,
j
)
global
x
y
xi =
x(i);
yi =
y(i);
xj =
x(j);
yj =
y(j);
xj =
wrap(xj,
xi
);
yj =
wrap(yj,
yi
);
dx =
xi
-
xj
;
dy =
yi
-
yj
;
r =
sqrt(dx^2
+
dy
^2);
endfunction
d =
zeros(n,
1)
#
density
for
i =
1:n;
for
j =
1:n
if
i =
=
j
;
continue
;
endif
r =
dist(i,
j
);
if
r
>
rc; continue; endif
w = wk(i)
endfor; endfor
poc/ker/cubic.mac
0 → 100644
View file @
750b00f8
/* cubic spline kernel */
v0: [ 1, b0, c0, d0];
v1: [a1, b1, c1, d1]
mo: [1, x, x^2, x^3];
f0: v0 . mo;
f1: v1 . mo;
df0: diff(f0, x);
df1: diff(f1, x);
ddf0: diff(f0, x, 2);
ddf1: diff(f1, x, 2);
e(v, f):=subst('x = v, f);
eq: [
e(0, df0),
e(2, f1), e(2, df1), e(2, ddf1),
e(1, f0 - f1), e(1, df0 - df1), e(1, ddf0 - ddf1)];
v : append(v0, v1);
v : listofvars(v);
so: linsolve(eq, v);
f00: subst(so, f0);
f10: subst(so, f1);
f00: horner(f00);
f10: factor(f10);
draw2d(explicit(f00, x, 0, 1), explicit(f10, x, 1, 2)) $
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment