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