RealTimeTransport 1.0.0
Real-time simulation of quantum transport processes
Loading...
Searching...
No Matches
BlockDiagonalCheb.h
Go to the documentation of this file.
1//
2// This Source Code Form is subject to the terms of the Mozilla Public
3// License, v. 2.0. If a copy of the MPL was not distributed with this
4// file, You can obtain one at https://mozilla.org/MPL/2.0/.
5//
6
7///
8/// \file BlockDiagonalCheb.h
9///
10/// \brief Chebyshev interpolation of block diagonal matrices.
11///
12
13#ifndef REAL_TIME_TRANSPORT_BLOCK_MATRICES_BLOCK_DIAGONAL_CHEB_H
14#define REAL_TIME_TRANSPORT_BLOCK_MATRICES_BLOCK_DIAGONAL_CHEB_H
15
16#include <functional>
17#include <memory>
18
19#include <SciCore/Definitions.h>
20
21#include "../RealTimeTransport_export.h"
23
24namespace cereal
25{
26class BinaryInputArchive;
27class BinaryOutputArchive;
28
29class PortableBinaryInputArchive;
30class PortableBinaryOutputArchive;
31} // namespace cereal
32
33namespace SciCore
34{
35template <MatrixOrScalarType T>
36class ChebAdaptive;
37}
38
39namespace tf
40{
41class Executor;
42}
43
44namespace RealTimeTransport
45{
46
47///
48/// @brief This class represents a parameter dependent block diagonal matrix.
49///
50/// This class represents a parameter dependent block diagonal matrix. The parameter is typically
51/// the time \f$ t \f$. The time dependence is represented through a Chebyshev interpolation.
52///
54{
55 public:
56 /// @brief Type representing the matrix elements.
58
59 /// @brief Type representing a matrix block at a specific time.
61
62 ///
63 /// @brief Constructs an empty interpolation object.
64 ///
66
67 ~BlockDiagonalCheb();
68
69 ///
70 /// @brief Move constructor.
71 ///
73
74 ///
75 /// @brief Copy constructor.
76 ///
78
79 ///
80 /// @brief Move assignment operator.
81 ///
83
84 ///
85 /// @brief Copy assignment operator.
86 ///
88
89 ///
90 /// \brief Creates a piecewise Chebyshev interpolation of the function \f$f(t)\f$ with \f$t\in[a,b]\f$.
91 ///
92 /// \param f The function for which the piecewise Chebyshev approximation is computed.
93 /// The first parameter refers to the block index, the second to the time argument.
94 /// \param nBlocks The number of blocks.
95 /// \param a Lower interval point.
96 /// \param b Upper interval point.
97 /// \param epsAbs Absolute error goal.
98 /// \param epsRel Relative error goal.
99 /// \param hMin The minimum allowed interval length.
100 /// \param ok Set to _true_ if error goal was achieved, otherwise set to _false_.
101 ///
103 const std::function<MatrixType(int, SciCore::Real)>& f,
104 int nBlocks,
105 SciCore::Real a,
106 SciCore::Real b,
107 SciCore::Real epsAbs,
108 SciCore::Real epsRel,
109 SciCore::Real hMin,
110 bool* ok = nullptr);
111
112 ///
113 /// \brief Creates a piecewise Chebyshev interpolation of the function \f$f(t)\f$ with \f$t\in[a,b]\f$ in parallel.
114 ///
115 /// \param f The function for which the piecewise Chebyshev approximation is computed.
116 /// The first parameter refers to the block index, the second to the time argument.
117 /// \param nBlocks The number of blocks.
118 /// \param a Lower interval point.
119 /// \param b Upper interval point.
120 /// \param epsAbs Absolute error goal.
121 /// \param epsRel Relative error goal.
122 /// \param hMin The minimum allowed interval length.
123 /// \param executor Taskflow executor managing the threads.
124 /// \param ok Set to _true_ if error goal was achieved, otherwise set to _false_.
125 ///
127 const std::function<MatrixType(int, SciCore::Real)>& f,
128 int nBlocks,
129 SciCore::Real a,
130 SciCore::Real b,
131 SciCore::Real epsAbs,
132 SciCore::Real epsRel,
133 SciCore::Real hMin,
134 tf::Executor& executor,
135 bool* ok = nullptr);
136
137 // f(i, t) returns block i at time t
138 BlockDiagonalCheb(
139 const std::function<MatrixType(int, SciCore::Real)>& f,
140 int nBlocks,
141 const std::vector<SciCore::RealVector>& sections,
142 SciCore::Real epsAbs,
143 SciCore::Real epsRel,
144 SciCore::Real hMin,
145 bool* ok = nullptr);
146
147 BlockDiagonalCheb(
148 const std::function<MatrixType(int, SciCore::Real)>& f,
149 int nBlocks,
150 const std::vector<SciCore::RealVector>& sections,
151 SciCore::Real epsAbs,
152 SciCore::Real epsRel,
153 SciCore::Real hMin,
154 tf::Executor& executor,
155 bool* ok = nullptr);
156
157 BlockDiagonalCheb(std::vector<SciCore::ChebAdaptive<MatrixType>>&& blocks) noexcept;
158
159 ///
160 /// @brief Equality comparison operator.
161 ///
162 bool operator==(const BlockDiagonalCheb& other) const;
163
164 ///
165 /// @brief Inequality comparison operator.
166 ///
167 bool operator!=(const BlockDiagonalCheb& other) const;
168
169 ///
170 /// @brief Returns the number of matrix blocks.
171 ///
172 int numBlocks() const noexcept;
173
174 ///
175 /// @brief Lower limit of the interplation interval.
176 ///
178
179 ///
180 /// @brief Upper limit of the interplation interval.
181 ///
183
184 ///
185 /// @brief Returns the full interpolated matrix at time \f$ t \f$.
186 ///
187 BlockDiagonalMatrix operator()(SciCore::Real t) const;
188
189 ///
190 /// @brief Returns block \a i of the interpolated matrix at time \f$ t \f$.
191 ///
193
194 ///
195 /// @brief Returns the interpolation object for block \a i.
196 ///
197 const SciCore::ChebAdaptive<MatrixType>& block(int i) const;
198
199 ///
200 /// \brief Computes the derivative of the represented function and returns it as a new object.
201 ///
203
204 ///
205 /// \brief Computes the integral of the represented function and returns it as a new object.
206 ///
208
209 std::vector<SciCore::RealVector> sections() const;
210
211 void serialize(cereal::BinaryInputArchive& archive);
212 void serialize(cereal::BinaryOutputArchive& archive);
213 void serialize(cereal::PortableBinaryInputArchive& archive);
214 void serialize(cereal::PortableBinaryOutputArchive& archive);
215
216 private:
217 struct Impl;
218 std::unique_ptr<Impl> _pimpl;
219};
220
221} // namespace RealTimeTransport
222
223#endif // REAL_TIME_TRANSPORT_BLOCK_MATRICES_BLOCK_DIAGONAL_CHEB_H
#define REALTIMETRANSPORT_EXPORT
Definition RealTimeTransport_export.h:15
This class represents a parameter dependent block diagonal matrix.
Definition BlockDiagonalCheb.h:54
BlockDiagonalCheb(const std::function< MatrixType(int, SciCore::Real)> &f, int nBlocks, SciCore::Real a, SciCore::Real b, SciCore::Real epsAbs, SciCore::Real epsRel, SciCore::Real hMin, tf::Executor &executor, bool *ok=nullptr)
Creates a piecewise Chebyshev interpolation of the function with in parallel.
bool operator==(const BlockDiagonalCheb &other) const
Equality comparison operator.
BlockDiagonalCheb integrate() const
Computes the integral of the represented function and returns it as a new object.
BlockDiagonalCheb(const std::function< MatrixType(int, SciCore::Real)> &f, int nBlocks, SciCore::Real a, SciCore::Real b, SciCore::Real epsAbs, SciCore::Real epsRel, SciCore::Real hMin, bool *ok=nullptr)
Creates a piecewise Chebyshev interpolation of the function with .
BlockDiagonalCheb & operator=(BlockDiagonalCheb &&other) noexcept
Move assignment operator.
SciCore::Real lowerLimit() const
Lower limit of the interplation interval.
MatrixType operator()(int i, SciCore::Real t) const
Returns block i of the interpolated matrix at time .
BlockDiagonalCheb(const BlockDiagonalCheb &other)
Copy constructor.
BlockDiagonalCheb()
Constructs an empty interpolation object.
BlockDiagonalCheb & operator=(const BlockDiagonalCheb &other)
Copy assignment operator.
SciCore::Real upperLimit() const
Upper limit of the interplation interval.
bool operator!=(const BlockDiagonalCheb &other) const
Inequality comparison operator.
BlockDiagonalCheb(BlockDiagonalCheb &&other) noexcept
Move constructor.
const SciCore::ChebAdaptive< MatrixType > & block(int i) const
Returns the interpolation object for block i.
BlockDiagonalCheb diff() const
Computes the derivative of the represented function and returns it as a new object.
int numBlocks() const noexcept
Returns the number of matrix blocks.
BlockDiagonalMatrix operator()(SciCore::Real t) const
Returns the full interpolated matrix at time .
Represents a block diagonal matrix.
Definition BlockDiagonalMatrix.h:33