main
test-branch
|
Last change
on this file since bd7a43e was ea777aa, checked in by Alex Wilton <awilton@…>, 3 years ago |
|
Moved examples, include, build_default.properties, common.xml, and README out from dev.civl.com into the root of the repo.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@5704 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
687 bytes
|
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify derivative.cvl
|
|---|
| 3 | */
|
|---|
| 4 | #include <civlc.cvh>
|
|---|
| 5 |
|
|---|
| 6 | $input double h;
|
|---|
| 7 | $input int num_elements;
|
|---|
| 8 | $assume( num_elements > 0);
|
|---|
| 9 | $input double initial[num_elements];
|
|---|
| 10 | $output double final[num_elements];
|
|---|
| 11 | double working[num_elements];
|
|---|
| 12 |
|
|---|
| 13 | void differentiate(double h, int n, double y[], double result[]){
|
|---|
| 14 | int i;
|
|---|
| 15 |
|
|---|
| 16 | for(i = 1; i < n-1; i++)
|
|---|
| 17 | {
|
|---|
| 18 | result[i] = (y[i+1]-y[i-1])/(2*h);
|
|---|
| 19 | }
|
|---|
| 20 | result[0] = (y[1]-y[0])/h;
|
|---|
| 21 | result[n-1] = (y[n-1] - y[n-2])/h;
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void main() {
|
|---|
| 25 | int i;
|
|---|
| 26 |
|
|---|
| 27 | $assume(h > 0);
|
|---|
| 28 | $assume(num_elements > 2 && num_elements <= 5);
|
|---|
| 29 | differentiate(h, num_elements, initial, working);
|
|---|
| 30 | for(i=0; i < num_elements; i++) {
|
|---|
| 31 | final[i] = working[i];
|
|---|
| 32 | }
|
|---|
| 33 | }
|
|---|
| 34 |
|
|---|
| 35 |
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.