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