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