Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Menu
Open sidebar
Selwyn Simsek
gsll
Commits
d87c9b66
Commit
d87c9b66
authored
Nov 11, 2009
by
TTCA Vukovic
Committed by
Liam Healy
Nov 11, 2009
Browse files
Added example of `evaluate-integral'
parent
b4af2289
Changes
1
Show whitespace changes
Inline
Side-by-side
interpolation/spline-example.lisp
View file @
d87c9b66
...
...
@@ -25,3 +25,24 @@
collect
(
list
xi
(
evaluate
spline
xi
:acceleration
acc
)))))
(
save-test
interpolation
(
spline-example
0.1d0
))
(
defun
evaluate-integral-example
(
&optional
(
intervals
4
))
"Evaluate integral of sin(x) in interval 0-pi. sin(x) is tabulated
over a 0-2pi interval and interpolated with
+periodic-cubic-spline-interpolation+"
(
let*
((
nodes
(
1+
intervals
))
(
max-node
(
1-
nodes
))
(
xarr
(
loop
with
step
=
(
/
(
*
2.0
pi
)
intervals
)
for
i
from
0
upto
max-node
collect
(
*
i
step
)))
(
xmarr
(
make-marray
'double-float
:initial-contents
xarr
))
;; cannot use (loop for x on (cl-array xmarr)...) -- c function gives error
(
ymarr
(
make-marray
'double-float
:initial-contents
(
loop
for
x
in
xarr
collect
(
sin
x
))))
(
acc
(
make-acceleration
))
(
spline
(
make-spline
+periodic-cubic-spline-interpolation+
xmarr
ymarr
)))
(
evaluate-integral
spline
0d0
(
coerce
pi
'double-float
)
:acceleration
acc
)))
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