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