1.23
2.0
main
test-branch
|
Last change
on this file since ac5660f was 06b8536c, checked in by Stephen Siegel <siegel@…>, 13 years ago |
|
Starting to clean up examples, but adding some extra versions of matmat as bug have been revealed.
Optimized somewhat evaluation of conditional (if then else) expressions, though I now feel this construct should be translated away.
Added a method to get the canonic ID of a state, minor changes.
git-svn-id: svn://vsl.cis.udel.edu/civl/trunk@257 fb995dde-84ed-4084-dfe6-e5aef3e2452c
|
-
Property mode
set to
100644
|
|
File size:
578 bytes
|
| Line | |
|---|
| 1 | /* assoc.cvl: adds the elements of an array in two different
|
|---|
| 2 | * orders, and checks the results agree. This relies on the
|
|---|
| 3 | * use of real arithmetic, as opposed to floating-point
|
|---|
| 4 | * arithmetic.
|
|---|
| 5 | *
|
|---|
| 6 | * Should be run at commandline specifying an upper bound on
|
|---|
| 7 | * the length of the array. Example:
|
|---|
| 8 | * civl verify -inputB=100 assoc.cvl
|
|---|
| 9 | */
|
|---|
| 10 | #include <civlc.h>
|
|---|
| 11 | $input int B;
|
|---|
| 12 | $input int n;
|
|---|
| 13 | $assume 0<=n && n<B;
|
|---|
| 14 | $input double a[n];
|
|---|
| 15 |
|
|---|
| 16 | void main() {
|
|---|
| 17 | double s0 = 0.0;
|
|---|
| 18 | double s1 = 0.0;
|
|---|
| 19 |
|
|---|
| 20 | for (int i = 0; i < n; i++) {
|
|---|
| 21 | s0 += a[i];
|
|---|
| 22 | s1 += a[n-1-i];
|
|---|
| 23 | }
|
|---|
| 24 | $assert s0 == s1;
|
|---|
| 25 | }
|
|---|
Note:
See
TracBrowser
for help on using the repository browser.