xref: /petsc/src/sys/tests/ex4.c (revision 9371c9d470a9602b6d10a8bf50c9b2280a79e45a) !
1 #include <petscsys.h>
2 
3 static char help[] = "Test PetscComplex binary operators.\n";
4 
5 int main(int argc, char **argv) {
6   PetscFunctionBeginUser;
7   PetscCall(PetscInitialize(&argc, &argv, NULL, help));
8   {
9     int         i = 2;
10     float       f = 2;
11     double      d = 2;
12     PetscInt    j = 2;
13     PetscReal   r = 2;
14     PetscScalar z;
15 
16 #define TestOps(BOP, IOP) \
17   do { \
18     z = i; \
19     z = z BOP i; \
20     z = i BOP z; \
21     z IOP     i; \
22     (void)(z == i); \
23     (void)(z != i); \
24     z = f; \
25     z = z BOP f; \
26     z = f BOP z; \
27     z IOP     f; \
28     (void)(z == f); \
29     (void)(z != f); \
30     z = d; \
31     z = z BOP d; \
32     z = d BOP z; \
33     z IOP     d; \
34     (void)(z == d); \
35     (void)(z != d); \
36     z = j; \
37     z = z BOP j; \
38     z = r BOP z; \
39     z IOP     j; \
40     (void)(z == j); \
41     (void)(z != j); \
42     z = r; \
43     z = z BOP r; \
44     z = r BOP z; \
45     z IOP     r; \
46     (void)(z == r); \
47     (void)(z != r); \
48   } while (0)
49 
50     TestOps(+, +=);
51     TestOps(-, -=);
52     TestOps(*, *=);
53     TestOps(/, /=);
54   }
55   PetscCall(PetscFinalize());
56   return 0;
57 }
58 
59 /*TEST
60 
61    build:
62       requires: complex
63 
64    test:
65 
66 TEST*/
67