1 /// @file 2 /// Test summing of a pair of vectors 3 /// \test Test summing of a pair of vectors 4 #include <ceed.h> 5 #include <math.h> 6 7 int main(int argc, char **argv) { 8 Ceed ceed; 9 CeedVector x, y; 10 CeedInt n; 11 CeedScalar a[10]; 12 const CeedScalar *b; 13 14 CeedInit(argv[1], &ceed); 15 16 n = 10; 17 CeedVectorCreate(ceed, n, &x); 18 CeedVectorCreate(ceed, n, &y); 19 for (CeedInt i=0; i<n; i++) 20 a[i] = 10 + i; 21 CeedVectorSetArray(x, CEED_MEM_HOST, CEED_COPY_VALUES, a); 22 CeedVectorSetArray(y, CEED_MEM_HOST, CEED_COPY_VALUES, a); 23 24 CeedVectorAXPY(y, -0.5, x); 25 26 CeedVectorGetArrayRead(y, CEED_MEM_HOST, &b); 27 for (CeedInt i=0; i<n; i++) 28 if (fabs(b[i] - (10.0 + i)/2 ) > 1e-14) 29 // LCOV_EXCL_START 30 printf("Error in alpha x + y, computed: %f actual: %f\n", b[i], 31 (10.0 + i)/2); 32 // LCOV_EXCL_STOP 33 CeedVectorRestoreArrayRead(y, &b); 34 35 CeedVectorDestroy(&x); 36 CeedVectorDestroy(&y); 37 CeedDestroy(&ceed); 38 return 0; 39 } 40