xref: /libCEED/include/ceed/jit-source/gallery/ceed-scale.h (revision 70dc8078dbe287928145230e5a499c81da54eabb)
1 // Copyright (c) 2017-2024, Lawrence Livermore National Security, LLC and other CEED contributors.
2 // All Rights Reserved. See the top-level LICENSE and NOTICE files for details.
3 //
4 // SPDX-License-Identifier: BSD-2-Clause
5 //
6 // This file is part of CEED:  http://github.com/ceed
7 
8 /**
9   @brief  Scaling QFunction that scales inputs
10 **/
11 
12 #include <ceed.h>
13 
14 CEED_QFUNCTION(Scale)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
15   // Ctx holds field size
16   const CeedInt size = *(CeedInt *)ctx;
17 
18   // in[0] is input, size (Q*size)
19   // in[1] is scaling factor, size (Q*size)
20   const CeedScalar *input = in[0];
21   const CeedScalar *scale = in[1];
22   // out[0] is output, size (Q*size)
23   CeedScalar *output = out[0];
24 
25   // Quadrature point loop
26   CeedPragmaSIMD for (CeedInt i = 0; i < Q * size; i++) { output[i] = input[i] * scale[i]; }  // End of Quadrature Point Loop
27   return 0;
28 }
29