1.23
2.0
main
test-branch
| Line | |
|---|
| 1 | /* Commandline execution:
|
|---|
| 2 | * civl verify -inputrows=3 -inputcols=3 laplace.cvl
|
|---|
| 3 | * */
|
|---|
| 4 | #include <civlc.cvh>
|
|---|
| 5 |
|
|---|
| 6 | $input double h;
|
|---|
| 7 | $input int rows = 3;
|
|---|
| 8 | $input int cols = 3;
|
|---|
| 9 | $input double u[rows][cols];
|
|---|
| 10 | double result[rows][cols];
|
|---|
| 11 | $assume(h > 0);
|
|---|
| 12 | $abstract $contin(4) $real phi($real x, $real y);
|
|---|
| 13 | $assume($forall {m=0 .. rows-1} $forall {n=0 .. cols-1} u[m][n] == phi(m*h, n*h));
|
|---|
| 14 |
|
|---|
| 15 | void laplace() {
|
|---|
| 16 | for (int i = 1; i < rows-1; i++) {
|
|---|
| 17 | for (int j = 1; j < cols-1; j++) {
|
|---|
| 18 | result[i][j] = (u[i-1][j]+u[i][j-1]-4*u[i][j]+u[i+1][j]+u[i][j+1])/(h*h);
|
|---|
| 19 | }
|
|---|
| 20 | }
|
|---|
| 21 | $assert($uniform {i=1 .. rows-2} $uniform {j=1 .. cols-2} result[i][j] - ($D[phi,{x,2}](i*h,j*h)+$D[phi,{y,2}](i*h,j*h)) == $O(h*h));
|
|---|
| 22 | }
|
|---|
| 23 |
|
|---|
| 24 | void main() {
|
|---|
| 25 | laplace();
|
|---|
| 26 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.