1 /// @file 2 /// Test creation, setting, reading, restoring, and destroying of a vector 3 /// \test Test creation, setting, reading, restoring, and destroying of a vector 4 #include <ceed.h> 5 6 int main(int argc, char **argv) { 7 Ceed ceed; 8 CeedVector x; 9 CeedInt n; 10 CeedScalar a[10]; 11 const CeedScalar *b; 12 13 CeedInit(argv[1], &ceed); 14 15 n = 10; 16 CeedVectorCreate(ceed, n, &x); 17 for (CeedInt i=0; i<n; i++) 18 a[i] = 10 + i; 19 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, a); 20 21 CeedVectorGetArrayRead(x, CEED_MEM_HOST, &b); 22 for (CeedInt i=0; i<n; i++) 23 if (b[i] != 10+i) 24 // LCOV_EXCL_START 25 printf("Error reading array b[%d] = %f",i,(CeedScalar)b[i]); 26 // LCOV_EXCL_STOP 27 CeedVectorRestoreArrayRead(x, &b); 28 29 CeedVectorDestroy(&x); 30 CeedDestroy(&ceed); 31 return 0; 32 } 33