RealTimeTransport 1.0.0
Real-time simulation of quantum transport processes
Loading...
Searching...
No Matches
MatrixExp.h
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#ifndef REAL_TIME_TRANSPORT_BLOCK_MATRICES_MATRIX_EXP_H
8#define REAL_TIME_TRANSPORT_BLOCK_MATRICES_MATRIX_EXP_H
9
10#include <vector>
11
12#include <SciCore/Definitions.h>
13
14#include "../Error.h"
15#include "../RealTimeTransport_export.h"
17
18namespace RealTimeTransport
19{
20
21// Computes for a given Matrix A the matrix exponential exp(t*A)
22class REALTIMETRANSPORT_EXPORT MatrixExp
23{
24 public:
25 MatrixExp() noexcept = default;
26 MatrixExp(MatrixExp&& other) noexcept = default;
27 MatrixExp(const MatrixExp& other) = default;
28 MatrixExp& operator=(MatrixExp&& other) noexcept = default;
29 MatrixExp& operator=(const MatrixExp& other) noexcept = default;
30
31 MatrixExp(const SciCore::Matrix& A);
32
33 void initialize(const SciCore::Matrix& A);
34
35 SciCore::Matrix operator()(SciCore::Real t) const;
36 SciCore::Matrix expm1(SciCore::Real t) const;
37
38 private:
39 bool _useEigendecomposition;
40 SciCore::Vector _eigenvalues;
41 std::vector<SciCore::Matrix> _projectors;
42};
43
44class REALTIMETRANSPORT_EXPORT BlockDiagonalMatrixExp
45{
46 public:
47 BlockDiagonalMatrixExp() noexcept = default;
48 BlockDiagonalMatrixExp(BlockDiagonalMatrixExp&& other) noexcept = default;
49 BlockDiagonalMatrixExp(const BlockDiagonalMatrixExp& other) = default;
50 BlockDiagonalMatrixExp& operator=(BlockDiagonalMatrixExp&& other) noexcept = default;
51 BlockDiagonalMatrixExp& operator=(const BlockDiagonalMatrixExp& other) noexcept = default;
52
53 BlockDiagonalMatrixExp(const BlockDiagonalMatrix& A);
54
55 void initialize(const BlockDiagonalMatrix& A);
56
57 BlockDiagonalMatrix operator()(SciCore::Real t) const;
58 BlockDiagonalMatrix::MatrixType operator()(int blockIndex, SciCore::Real t) const;
59
60 BlockDiagonalMatrix expm1(SciCore::Real t) const;
61 BlockDiagonalMatrix::MatrixType expm1(int blockIndex, SciCore::Real t) const;
62
63 private:
64 std::vector<MatrixExp> _blocks;
65};
66
67} // namespace RealTimeTransport
68
69#endif // REAL_TIME_TRANSPORT_BLOCK_MATRICES_MATRIX_EXP_H
#define REALTIMETRANSPORT_EXPORT
Definition RealTimeTransport_export.h:15
Represents a block diagonal matrix.
Definition BlockDiagonalMatrix.h:33