1 /// @file 2 /// Test CeedVectorGetArrayWrite to modify array 3 /// \test Test CeedVectorGetArrayWrite 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; 11 12 CeedInit(argv[1], &ceed); 13 14 CeedVectorCreate(ceed, n, &x); 15 16 CeedVectorGetArrayWrite(x, CEED_MEM_HOST, &a); 17 for (CeedInt i = 0; i < n; i++) a[i] = 3 * i; 18 CeedVectorRestoreArray(x, &a); 19 20 CeedVectorGetArrayRead(x, CEED_MEM_HOST, (const CeedScalar **)&a); 21 for (CeedInt i = 0; i < n; i++) { 22 if (a[i] != (CeedScalar)(3 * i)) printf("Error writing array a[%" CeedInt_FMT "] = %f\n", i, a[i]); 23 } 24 CeedVectorRestoreArrayRead(x, (const CeedScalar **)&a); 25 26 CeedVectorDestroy(&x); 27 CeedDestroy(&ceed); 28 return 0; 29 } 30