FEAT 3
Finite Element Analysis Toolbox
Loading...
Searching...
No Matches
axpy_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_AXPY_GENERIC_HPP
8#define KERNEL_LAFEM_ARCH_AXPY_GENERIC_HPP 1
9
10#ifndef KERNEL_LAFEM_ARCH_AXPY_HPP
11#error "Do not include this implementation-only header file directly!"
12#endif
13
14#include <kernel/util/math.hpp>
15#include <kernel/util/tiny_algebra.hpp>
16#include <kernel/util/memory_pool.hpp>
17
18namespace FEAT
19{
20 namespace LAFEM
21 {
22 namespace Arch
23 {
24 template <typename DT_>
25 void Axpy::value_generic(DT_ * r, const DT_ a, const DT_ * const x, const Index size)
26 {
27 if (r == x)
28 {
29 FEAT_PRAGMA_OMP(parallel for)
30 for (Index i = 0 ; i < size ; ++i)
31 {
32 r[i] *= DT_(1) + a;
33 }
34 }
35 else
36 {
37 FEAT_PRAGMA_OMP(parallel for)
38 for (Index i = 0 ; i < size ; ++i)
39 {
40 r[i] += a * x[i];
41 }
42 }
43 }
44
45 template <typename ValueType_>
46 void Axpy::value_blocked_generic(ValueType_ * r, const ValueType_ a, const ValueType_ * const x, const Index size)
47 {
48 FEAT_PRAGMA_OMP(parallel for)
49 for (Index i = 0 ; i < size ; ++i)
50 {
51 for(int j(0); j < ValueType_::n; ++j)
52 r[i][j] += a[j] * x[i][j];
53 }
54 }
55 } // namespace Arch
56 } // namespace LAFEM
57} // namespace FEAT
58
59#endif // KERNEL_LAFEM_ARCH_AXPY_GENERIC_HPP
FEAT namespace.
Definition: adjactor.hpp:12
std::uint64_t Index
Index data type.