3 #include "../types.hpp" 4 #include "../wavepackets/shapes/tiny_multi_index.hpp" 10 template <
class Matrix>
14 template <
class Matrix>
21 template <
class Matrix>
27 static const int N = Matrix::RowsAtCompileTime;
28 static const int M = Matrix::ColsAtCompileTime;
34 : g( adaptor ), i( i ) {}
55 template <
class Matrix>
59 static const int N = Matrix::RowsAtCompileTime;
60 static const int M = Matrix::ColsAtCompileTime;
73 return matrix.template block<N, 1>( 0,
i );
102 template <
class Matrix,
template <
typename...>
class Grid = std::vector>
105 const int N = m.rows();
106 const int M = m.cols();
108 Grid<grid_element_type<Matrix> > result( M );
109 auto it = result.begin();
111 for (
int i = 0;
i <
M; ++
i ) {
112 *it = m.template block<N, 1>( 0,
i );
118 template <
class Matrix,
template <
typename...>
class Grid = std::vector>
133 const int N = Matrix::RowsAtCompileTime;
138 for (
int i = 0; it !=
g.end(); ++
i, ++it ) {
139 m.template block<N, 1>( 0,
i ) = *it;
145 template<
class Packet>
151 for (
const auto& component: packet.components()) {
152 size += component.coefficients().size();
156 coefficients.resize(size);
160 for(
auto& component : packet.components()) {
161 int j_size = component.coefficients().size();
162 for (
int j = 0; j < j_size; ++j) {
163 coefficients[j+j_offset] = component.coefficients()[j];
175 for (
const auto& component: packet.components()) {
176 size += component.coefficients().size();
181 for(
auto& component : packet.components()) {
182 int j_size = component.coefficients().size();
183 for (
int j = 0; j < j_size; ++j) {
184 component.coefficients()[j] = coefficients[j+j_offset];
191 template<
int D,
class MultiIndex>
Grid< grid_element_type< Matrix > > matrix_to_grid(const Matrix &m)
Copies a Eigen::Matrix into a grid.
Definition: adaptors.hpp:103
GVector< complex_t, R > CVector
Definition: types.hpp:50
Forward iterator for the MatrixToGrid class.
Definition: adaptors.hpp:22
Definition: coefficients_file_parser.cpp:10
Coefficients & coefficients()
Grants writeable access to the coefficients of the wavepacket.
Definition: hawp_commons.hpp:262
GMatrix< I, R, 1 > GVector
Definition: types.hpp:47
static CVector< Eigen::Dynamic > to(const Packet &packet)
Definition: adaptors.hpp:147
static void from(const CVector< Eigen::Dynamic > &coefficients, Packet &packet)
Definition: adaptors.hpp:171
GVector< typename Matrix::Scalar, N > grid_element_type
Definition: adaptors.hpp:29
static const int M
Definition: adaptors.hpp:28
MatrixToGridIterator(MatrixToGrid< Matrix > &adaptor, int i)
Definition: adaptors.hpp:33
int i
Definition: adaptors.hpp:30
size_t size() const
Definition: adaptors.hpp:66
MatrixToGrid< Matrix > & g
Definition: adaptors.hpp:25
grid_element_type operator[](int i) const
Definition: adaptors.hpp:72
static const CVector< Eigen::Dynamic > & to(const wavepackets::ScalarHaWp< D, MultiIndex > &packet)
Definition: adaptors.hpp:193
MatrixToGrid(const Matrix &matrix)
Definition: adaptors.hpp:70
void operator++()
Definition: adaptors.hpp:39
Adaptor which accepts an Eigen::Matrix and emulates some behavior of a std::vector.
Definition: adaptors.hpp:15
static void from(const CVector< Eigen::Dynamic > &coefficients, wavepackets::ScalarHaWp< D, MultiIndex > &packet)
Definition: adaptors.hpp:197
MatrixToGridIterator< Matrix > end() const
Definition: adaptors.hpp:79
Matrix grid_to_matrix(Grid< grid_element_type< Matrix > > g)
Copies a grid into a Eigen::Matrix.
Definition: adaptors.hpp:131
Concrete implementation of a scalar Hagedorn wavepacket.
Definition: hawp_commons.hpp:209
const Matrix & matrix
Definition: adaptors.hpp:63
static const int N
Definition: adaptors.hpp:27
GVector< typename Matrix::Scalar, N > grid_element_type
Definition: adaptors.hpp:61
MatrixToGridIterator< Matrix > begin() const
Definition: adaptors.hpp:76
GVector< typename Matrix::Scalar, Matrix::RowsAtCompileTime > grid_element_type
Definition: adaptors.hpp:12
bool operator!=(MatrixToGridIterator< Matrix > other) const
Definition: adaptors.hpp:35
Definition: adaptors.hpp:146
grid_element_type operator*() const
Definition: adaptors.hpp:42