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 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] = 0; 16 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_USE_POINTER, array); 17 18 { 19 CeedScalar *writable_array; 20 21 CeedVectorGetArray(x, CEED_MEM_HOST, &writable_array); 22 writable_array[3] = -3.14; 23 CeedVectorRestoreArray(x, &writable_array); 24 } 25 26 if (array[3] != (CeedScalar)(-3.14)) printf("Error writing array[3] = %f\n", (CeedScalar)array[3]); 27 28 CeedVectorDestroy(&x); 29 CeedDestroy(&ceed); 30 return 0; 31 } 32