FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
scale_generic.hpp
1// FEAT3: Finite Element Analysis Toolbox, Version 3
2// Copyright (C) 2010 by Stefan Turek & the FEAT group
3// FEAT3 is released under the GNU General Public License version 3,
4// see the file 'copyright.txt' in the top level directory for details.
5
6#pragma once
7#ifndef KERNEL_LAFEM_ARCH_SCALE_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_SCALE_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_SCALE_HPP
11#error "Do not include this implementation-only header file directly!"
12#endif
13
14namespace FEAT
15{
16 namespace LAFEM
17 {
18 namespace Arch
19 {
20
21 template <typename DT_>
22 void Scale::value_generic(DT_ * r, const DT_ * const x, const DT_ s, const Index size)
23 {
24 if (x == r)
25 {
26 FEAT_PRAGMA_OMP(parallel for)
27 for (Index i = 0 ; i < size ; ++i)
28 {
29 r[i] *= s;
30 }
31 }
32 else
33 {
34 FEAT_PRAGMA_OMP(parallel for)
35 for (Index i = 0 ; i < size ; ++i)
36 {
37 r[i] = x[i] * s;
38 }
39 }
40 }
41
42 template <typename ValueType_>
43 void Scale::value_blocked_generic(ValueType_ * r, const ValueType_ * const x, const ValueType_ s, const Index size)
44 {
45 if (x == r)
46 {
47 FEAT_PRAGMA_OMP(parallel for)
48 for (Index i = 0 ; i < size ; ++i)
49 {
50 for(int j = 0; j < ValueType_::n; ++j)
51 {
52 r[i][j] *= s[j];
53 }
54 }
55 }
56 else
57 {
58 FEAT_PRAGMA_OMP(parallel for)
59 for (Index i = 0 ; i < size ; ++i)
60 {
61 for(int j = 0; j < ValueType_::n; ++j)
62 {
63 r[i][j] = x[i][j] * s[j];
64 }
65 }
66 }
67 }
68
69 } // namespace Arch
70 } // namespace LAFEM
71} // namespace FEAT
72
73#endif // KERNEL_LAFEM_ARCH_SCALE_GENERIC_HPP
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.