xref: /libCEED/include/ceed/jit-source/gallery/ceed-scale.h (revision 5a526491291e2ef13670ec99232a2cb0069702e5)
1 // Copyright (c) 2017-2025, 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 #include <ceed/types.h>
12 
13 CEED_QFUNCTION(Scale)(void *ctx, const CeedInt Q, const CeedScalar *const *in, CeedScalar *const *out) {
14   // Ctx holds field size
15   const CeedInt size = *(CeedInt *)ctx;
16 
17   // in[0] is input, size (Q*size)
18   // in[1] is scaling factor, size (Q*size)
19   const CeedScalar *input = in[0];
20   const CeedScalar *scale = in[1];
21   // out[0] is output, size (Q*size)
22   CeedScalar *output = out[0];
23 
24   // Quadrature point loop
25   CeedPragmaSIMD for (CeedInt i = 0; i < Q * size; i++) { output[i] = input[i] * scale[i]; }  // End of Quadrature Point Loop
26   return 0;
27 }
28