Loading [MathJax]/extensions/TeX/AMSmath.js
ESPResSo
Extensible Simulation Package for Research on Soft Matter Systems
All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Pages Concepts
AffineMap.hpp
Go to the documentation of this file.
1/*
2 * Copyright (C) 2010-2022 The ESPResSo project
3 *
4 * This file is part of ESPResSo.
5 *
6 * ESPResSo is free software: you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation, either version 3 of the License, or
9 * (at your option) any later version.
10 *
11 * ESPResSo is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program. If not, see <http://www.gnu.org/licenses/>.
18 */
19#ifndef CORE_EXTERNAL_FIELD_FIELDS_AFFINE_MAP_HPP
20#define CORE_EXTERNAL_FIELD_FIELDS_AFFINE_MAP_HPP
21
22#include "jacobian_type.hpp"
23#include <utils/Vector.hpp>
24
25#include <cstddef>
26
27namespace FieldCoupling {
28namespace Fields {
29
30/**
31 * @brief Affine transform of a vector field.
32 *
33 * Returns A * x + b, where * is matrix multiplication.
34 */
35template <typename T, std::size_t codim> class AffineMap {
36public:
37 using value_type =
39 using jacobian_type = detail::jacobian_type<T, codim>;
40
41private:
42 jacobian_type m_A;
43 value_type m_b;
44
45public:
46 AffineMap(const jacobian_type &A, const value_type &b) : m_A(A), m_b(b) {}
47
48 jacobian_type &A() { return m_A; }
49 value_type &b() { return m_b; }
50
51 value_type operator()(const Utils::Vector3d &pos, double = {}) const {
52 return m_A * pos + m_b;
53 }
54
55 jacobian_type jacobian(const Utils::Vector3d &, double = {}) const {
56 return m_A;
57 }
58
59 bool fits_in_box(const Utils::Vector3d &) const { return true; }
60};
61} // namespace Fields
62} // namespace FieldCoupling
63
64#endif
Vector implementation and trait types for boost qvm interoperability.
Affine transform of a vector field.
Definition AffineMap.hpp:35
value_type operator()(const Utils::Vector3d &pos, double={}) const
Definition AffineMap.hpp:51
AffineMap(const jacobian_type &A, const value_type &b)
Definition AffineMap.hpp:46
jacobian_type jacobian(const Utils::Vector3d &, double={}) const
Definition AffineMap.hpp:55
detail::jacobian_type< T, codim > jacobian_type
Definition AffineMap.hpp:39
typename Utils::decay_to_scalar< Utils::Vector< T, codim > >::type value_type
Definition AffineMap.hpp:38
bool fits_in_box(const Utils::Vector3d &) const
Definition AffineMap.hpp:59
Meta function to turns a Vector<1, T> into T.
Definition Vector.hpp:479