10 #include <Eigen/Dense> 12 #include "../types.hpp" 13 #include "../wavepackets/hawp_commons.hpp" 19 namespace innerproducts {
28 template<dim_t D,
class MultiIndex,
class QR>
39 using CDiagonalNN = Eigen::DiagonalMatrix<complex_t, Eigen::Dynamic>;
42 using op_t = std::function<CMatrix1N(CMatrixDN,RMatrixD1,dim_t,dim_t)>;
63 template<
class Packet>
66 const dim_t n_components = packet.n_components();
70 std::vector<dim_t> offsets(n_components);
72 for (
dim_t i = 1; i < n_components; ++i) {
73 offsets[i] = packet.component(i-1).coefficients().size();
77 size_t total_size = 0;
78 for (
auto& comp : packet.components()) {
79 total_size += comp.coefficients().size();
85 for (
dim_t i = 0; i < n_components; ++i) {
86 for (
dim_t j = 0; j < n_components; ++j) {
87 using namespace std::placeholders;
88 result.block(offsets[i], offsets[j],
89 packet.component(i).coefficients().size(),
90 packet.component(j).coefficients().size()) =
91 IP::build_matrix(packet.component(i), packet.component(j),
92 std::bind(op, _1, _2, i, j));
119 template<
class Pacbra,
class Packet>
121 const Packet& packet,
123 const dim_t n_components_bra = pacbra.n_components();
124 const dim_t n_components_ket = packet.n_components();
128 std::vector<dim_t> offsets_bra(n_components_bra);
130 for (
dim_t i = 1; i < n_components_bra; ++i) {
131 offsets_bra[i] = pacbra.component(i-1).coefficients().size();
134 std::vector<dim_t> offsets_ket(n_components_ket);
136 for (
dim_t i = 1; i < n_components_ket; ++i) {
137 offsets_ket[i] = packet.component(i-1).coefficients().size();
141 size_t total_rows = 0, total_cols = 0;
142 for (
auto& comp : pacbra.components()) {
143 total_rows += comp.coefficients().size();
145 for (
auto& comp : packet.components()) {
146 total_cols += comp.coefficients().size();
148 CMatrixNN result(total_rows, total_cols);
152 for (
dim_t i = 0; i < n_components_bra; ++i) {
153 for (
dim_t j = 0; j < n_components_ket; ++j) {
154 using namespace std::placeholders;
155 result.block(offsets_bra[i], offsets_ket[j],
156 pacbra.component(i).coefficients().size(),
157 packet.component(j).coefficients().size()) =
158 IP::build_matrix(pacbra.component(i), packet.component(j),
159 std::bind(op, _1, _2, i, j));
172 template<
class Packet>
175 const dim_t n_components = packet.n_components();
176 CMatrixN1 result(n_components * n_components, 1);
180 for (
dim_t i = 0; i < n_components; ++i) {
181 for (
dim_t j = 0; j < n_components; ++j) {
182 using namespace std::placeholders;
183 result(j + i * n_components) = packet.component(i).coefficients().adjoint() *
184 IP::build_matrix(packet.component(i), packet.component(j),
185 std::bind(op, _1, _2, i, j)) *
186 packet.component(j).coefficients();
198 template<
class Pacbra,
class Packet>
200 const Packet& packet,
202 const dim_t n_components_bra = pacbra.n_components();
203 const dim_t n_components_ket = packet.n_components();
204 CMatrixN1 result(n_components_bra * n_components_ket, 1);
208 for (
dim_t i = 0; i < n_components_bra; ++i) {
209 for (
dim_t j = 0; j < n_components_ket; ++j) {
210 using namespace std::placeholders;
211 result(j + i * n_components_ket) = pacbra.component(i).coefficients().adjoint() *
212 IP::build_matrix(pacbra.component(i), packet.component(j),
213 std::bind(op, _1, _2, i, j)) *
214 packet.component(j).coefficients();
224 if (i == j)
return CMatrix1N::Ones(1, nodes.cols());
225 else return CMatrix1N::Zero(1, nodes.cols());
CMatrix< Eigen::Dynamic, Eigen::Dynamic > CMatrixNN
Definition: vector_inner_product.hpp:32
Definition: coefficients_file_parser.cpp:10
Eigen::Matrix< real_t, R, C > RMatrix
Definition: types.hpp:22
CMatrix< 1, Eigen::Dynamic > CMatrix1N
Definition: vector_inner_product.hpp:33
CMatrix< D, D > CMatrixDD
Definition: vector_inner_product.hpp:36
CMatrix< D, Eigen::Dynamic > CMatrixDN
Definition: vector_inner_product.hpp:37
Class providing inhomogeneous inner product calculation of scalar wavepackets.
Definition: inhomogeneous_inner_product.hpp:30
static CMatrixNN build_matrix(const Packet &packet, const op_t &op=default_op)
Calculate the matrix of the inner product.
Definition: vector_inner_product.hpp:64
typename QR::NodeMatrix NodeMatrix
Definition: vector_inner_product.hpp:40
static CMatrix1N default_op(const CMatrixDN &nodes, const RMatrixD1 &pos, dim_t i, dim_t j)
Definition: vector_inner_product.hpp:221
Class providing inner product calculation of multi-component wavepackets.
Definition: vector_inner_product.hpp:29
RMatrix< D, 1 > RMatrixD1
Definition: vector_inner_product.hpp:38
Eigen::DiagonalMatrix< complex_t, Eigen::Dynamic > CDiagonalNN
Definition: vector_inner_product.hpp:39
static CMatrixN1 quadrature(const Packet &packet, const op_t &op=default_op)
Perform quadrature.
Definition: vector_inner_product.hpp:173
Eigen::Matrix< complex_t, R, C > CMatrix
Definition: types.hpp:19
typename QR::WeightVector WeightVector
Definition: vector_inner_product.hpp:41
CMatrix< Eigen::Dynamic, 1 > CMatrixN1
Definition: vector_inner_product.hpp:34
static CMatrixN1 quadrature_inhomog(const Pacbra &pacbra, const Packet &packet, const op_t &op=default_op)
Perform quadrature.
Definition: vector_inner_product.hpp:199
static CMatrixNN build_matrix_inhomog(const Pacbra &pacbra, const Packet &packet, const op_t &op=default_op)
Calculate the matrix of the inner product.
Definition: vector_inner_product.hpp:120
CMatrix< D, 1 > CMatrixD1
Definition: vector_inner_product.hpp:35
int dim_t
Definition: types.hpp:16
std::function< CMatrix1N(CMatrixDN, RMatrixD1, dim_t, dim_t)> op_t
Definition: vector_inner_product.hpp:42