1.23
2.0
main
test-branch
|
Last change
on this file since 5bc08d6 was 3ff27cf, checked in by Manchun Zheng <zmanchun@…>, 11 years ago |
|
updated examples since $assert/$assume has been changed to functions; fixed the model builder for the new side-effect remover.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@2085 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
844 bytes
|
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify -inputnum_elements=5 derivativeBad.cvl
|
|---|
| 3 | *
|
|---|
| 4 | * The assertion checked in this version erroneously expects the method to be fourth
|
|---|
| 5 | * order accurate in terms of h.
|
|---|
| 6 | * */
|
|---|
| 7 | #include<civlc.cvh>
|
|---|
| 8 | #include<stdio.h>
|
|---|
| 9 |
|
|---|
| 10 | $input double h;
|
|---|
| 11 | $input int num_elements = 5;
|
|---|
| 12 | $input double initial[num_elements];
|
|---|
| 13 | double working[num_elements];
|
|---|
| 14 | $abstract $contin(3) $real rho($real x);
|
|---|
| 15 | $assume(h > 0);
|
|---|
| 16 |
|
|---|
| 17 | void differentiate(double h, int n, double y[], double result[]){
|
|---|
| 18 | int i;
|
|---|
| 19 |
|
|---|
| 20 | $assume($forall {m=0 .. n-1} y[m] == rho(m*h));
|
|---|
| 21 | for(i = 1; i < n-1; i++)
|
|---|
| 22 | {
|
|---|
| 23 | result[i] = (y[i+1]-y[i-1])/(2*h);
|
|---|
| 24 | }
|
|---|
| 25 | result[0] = (y[1]-y[0])/h;
|
|---|
| 26 | result[n-1] = (y[n-1] - y[n-2])/h;
|
|---|
| 27 | $assert(($uniform {k=1 .. n-2} result[k]-$D[rho,{x,1}](k*h) == $O(h*h*h*h)));
|
|---|
| 28 | printf("Done.");
|
|---|
| 29 | }
|
|---|
| 30 |
|
|---|
| 31 | void main() {
|
|---|
| 32 | differentiate(h, num_elements, initial, working);
|
|---|
| 33 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.