/// @file /// Test CeedVectorSetArray to remove array access /// \test Test CeedVectorSetArray to remove array access #include #include int main(int argc, char **argv) { Ceed ceed; CeedVector x; const CeedInt n = 10; CeedScalar a[n]; CeedScalar *b, *c; CeedInit(argv[1], &ceed); CeedVectorCreate(ceed, n, &x); for (CeedInt i=0; i 1E-15) // LCOV_EXCL_START printf("Error taking array c[3] = %f", (double)c[3]); // LCOV_EXCL_STOP // Getting array should not modify a CeedVectorGetArray(x, CEED_MEM_HOST, &b); b[5] = -3.14; CeedVectorRestoreArray(x, &b); if (fabs(a[5] + 3.14) < 1E-15) // LCOV_EXCL_START printf("Error protecting array a[3] = %f", (double)a[3]); // LCOV_EXCL_STOP // Note: We do not need to free c because c == a was stack allocated. // If libCEED allocated c, then free() would be required. CeedVectorDestroy(&x); CeedDestroy(&ceed); return 0; }