xref: /libCEED/tests/t107-vector.c (revision bdee0278611904727ee35fcc2d0d7c3bf83db4c4)
1 /// @file
2 /// Test viewing a vector
3 /// \test Test viewing a vector
4 #include <ceed.h>
5 
6 int main(int argc, char **argv) {
7   Ceed       ceed;
8   CeedVector x;
9   CeedInt    len = 10;
10   CeedScalar array[len];
11 
12   CeedInit(argv[1], &ceed);
13 
14   CeedVectorCreate(ceed, len, &x);
15   for (CeedInt i = 0; i < len; i++) array[i] = len + i;
16   CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, array);
17 
18   CeedVectorView(x, "%12.8f", stdout);
19 
20   // Check tabs and CeedObject functionality
21   {
22     CeedVector x_copy = NULL;
23 
24     CeedVectorReferenceCopy(x, &x_copy);
25     CeedVectorSetNumViewTabs(x_copy, 1);
26     CeedObjectView((CeedObject)x_copy, stdout);
27     CeedObjectDestroy((CeedObject *)&x_copy);
28   }
29 
30   CeedVectorDestroy(&x);
31   CeedDestroy(&ceed);
32   return 0;
33 }
34