pomerol 2.2
Loading...
Searching...
No Matches
Misc.hpp
Go to the documentation of this file.
1//
2// This file is part of pomerol, an exact diagonalization library aimed at
3// solving condensed matter models of interacting fermions.
4//
5// Copyright (C) 2016-2026 A. Antipov, I. Krivenko and contributors
6//
7// This Source Code Form is subject to the terms of the Mozilla Public
8// License, v. 2.0. If a copy of the MPL was not distributed with this
9// file, You can obtain one at http://mozilla.org/MPL/2.0/.
10
15
16#ifndef POMEROL_INCLUDE_POMEROL_MISC_HPP
17#define POMEROL_INCLUDE_POMEROL_MISC_HPP
18
19#include <pomerol/Version.hpp>
20
21#include <libcommute/algebra_ids.hpp>
22#include <libcommute/loperator/loperator.hpp>
23#include <libcommute/loperator/state_vector.hpp>
24
25#ifndef DOXYGEN_SKIP
26#define EIGEN_YES_I_KNOW_SPARSE_MODULE_IS_NOT_STABLE_YET
27#endif
28#include <Eigen/Core>
29#include <Eigen/Sparse>
30
31#ifdef POMEROL_USE_OPENMP
32#include <omp.h>
33#endif
34
35#if __cplusplus >= 201402L
36#define POMEROL_DEPRECATED [[deprecated]]
37#else
38#define POMEROL_DEPRECATED
39#endif
40
41#include <array>
42#include <complex>
43#include <cstddef>
44#include <iostream>
45#include <type_traits>
46
48namespace Pomerol {
49
52
53#ifndef DOXYGEN_SKIP
54#define MSG_PREFIX __FILE__ << ":" << __LINE__ << ": "
55#endif
56#ifndef NDEBUG
58#define DEBUG(MSG) std::cout << MSG_PREFIX << MSG << '\n'
59#else
60#define DEBUG(MSG)
61#endif
63#define INFO(MSG) std::cout << MSG << '\n'
65#define INFO_NONEWLINE(MSG) std::cout << MSG
67#define ERROR(MSG) std::cerr << MSG_PREFIX << MSG << '\n'
68
70using RealType = double;
72using ComplexType = std::complex<double>;
73
75using ParticleIndex = unsigned int;
76
78using QuantumState = libcommute::sv_index_type;
79
82 Eigen::Matrix<ComplexType, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign | Eigen::RowMajor>;
83
86template <bool Complex> using MelemType = typename std::conditional<Complex, ComplexType, RealType>::type;
87
90template <typename ScalarType>
91using LOperatorType = libcommute::loperator<ScalarType, libcommute::fermion, libcommute::boson>;
92
95template <bool Complex>
96using LOperatorTypeRC = libcommute::loperator<MelemType<Complex>, libcommute::fermion, libcommute::boson>;
97
100template <bool Complex>
102 Eigen::Matrix<MelemType<Complex>, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign | Eigen::RowMajor>;
103
105using ComplexVectorType = Eigen::Matrix<ComplexType, Eigen::Dynamic, 1, Eigen::AutoAlign>;
107using RealVectorType = Eigen::Matrix<RealType, Eigen::Dynamic, 1, Eigen::AutoAlign>;
108
111template <bool Complex> using VectorType = Eigen::Matrix<MelemType<Complex>, Eigen::Dynamic, 1, Eigen::AutoAlign>;
112
115template <bool Complex> using ColMajorMatrixType = Eigen::SparseMatrix<MelemType<Complex>, Eigen::ColMajor>;
118template <bool Complex> using RowMajorMatrixType = Eigen::SparseMatrix<MelemType<Complex>, Eigen::RowMajor>;
119
121static ComplexType const I = ComplexType(0.0, 1.0); // 'static' to prevent linking problems
122
126 std::array<std::size_t, 3> const perm;
128 int const sign;
129 bool operator==(Permutation3 const& rhs) const;
130 bool operator!=(Permutation3 const& rhs) const;
131
136 friend std::ostream& operator<<(std::ostream& os, Permutation3 const& p);
137};
139extern std::array<Permutation3, 6> const permutations3;
140
144 std::array<std::size_t, 4> const perm;
146 int const sign;
147 bool operator==(Permutation4 const& rhs) const;
148 bool operator!=(Permutation4 const& rhs) const;
149
154 friend std::ostream& operator<<(std::ostream& os, Permutation4 const& p);
155};
157extern std::array<Permutation4, 24> const permutations4;
158
160enum Channel : int {
163 xPH
165std::ostream& operator<<(std::ostream& os, Channel channel);
166
173std::size_t hash_binned_real(double x, double bin_size);
174
176
177} // namespace Pomerol
178
179#endif // #ifndef POMEROL_INCLUDE_POMEROL_MISC_HPP
Pomerol version information.
typename std::conditional< Complex, ComplexType, RealType >::type MelemType
Definition Misc.hpp:86
std::ostream & operator<<(std::ostream &os, Channel channel)
Eigen::Matrix< ComplexType, Eigen::Dynamic, 1, Eigen::AutoAlign > ComplexVectorType
Dense complex vector.
Definition Misc.hpp:105
libcommute::loperator< ScalarType, libcommute::fermion, libcommute::boson > LOperatorType
Definition Misc.hpp:91
static ComplexType const I
Imaginary unit .
Definition Misc.hpp:121
Eigen::Matrix< MelemType< Complex >, Eigen::Dynamic, 1, Eigen::AutoAlign > VectorType
Definition Misc.hpp:111
std::array< Permutation3, 6 > const permutations3
An array of all 3! = 6 permutations of 3 elements.
Eigen::Matrix< ComplexType, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign|Eigen::RowMajor > ComplexMatrixType
Dense complex matrix.
Definition Misc.hpp:82
std::complex< double > ComplexType
Complex floating point type.
Definition Misc.hpp:72
libcommute::sv_index_type QuantumState
Index of a many-body state.
Definition Misc.hpp:78
std::array< Permutation4, 24 > const permutations4
An array of all 4! = 24 permutations of 4 elements.
libcommute::loperator< MelemType< Complex >, libcommute::fermion, libcommute::boson > LOperatorTypeRC
Definition Misc.hpp:96
unsigned int ParticleIndex
Index of a single particle degree of freedom.
Definition Misc.hpp:75
Channel
Channel, in which a susceptibility function is defined.
Definition Misc.hpp:160
Eigen::SparseMatrix< MelemType< Complex >, Eigen::ColMajor > ColMajorMatrixType
Definition Misc.hpp:115
Eigen::Matrix< MelemType< Complex >, Eigen::Dynamic, Eigen::Dynamic, Eigen::AutoAlign|Eigen::RowMajor > MatrixType
Definition Misc.hpp:102
double RealType
Real floating point type.
Definition Misc.hpp:70
Eigen::SparseMatrix< MelemType< Complex >, Eigen::RowMajor > RowMajorMatrixType
Definition Misc.hpp:118
Eigen::Matrix< RealType, Eigen::Dynamic, 1, Eigen::AutoAlign > RealVectorType
Dense real vector.
Definition Misc.hpp:107
std::size_t hash_binned_real(double x, double bin_size)
@ PP
Particle-particle channel.
Definition Misc.hpp:161
@ PH
Particle-hole channel.
Definition Misc.hpp:162
@ xPH
Crossed particle-hole channel.
Definition Misc.hpp:163
The main namespace of the library.
Definition pomerol.hpp:40
Permutation of 3 elements.
Definition Misc.hpp:124
std::array< std::size_t, 3 > const perm
A permuted list of integers (0, 1, 2)
Definition Misc.hpp:126
bool operator!=(Permutation3 const &rhs) const
bool operator==(Permutation3 const &rhs) const
int const sign
Signature of the permutation.
Definition Misc.hpp:128
friend std::ostream & operator<<(std::ostream &os, Permutation3 const &p)
Permutation of 4 elements.
Definition Misc.hpp:142
friend std::ostream & operator<<(std::ostream &os, Permutation4 const &p)
int const sign
Signature of the permutation.
Definition Misc.hpp:146
std::array< std::size_t, 4 > const perm
A permuted list of integers (0, 1, 2, 3)
Definition Misc.hpp:144
bool operator==(Permutation4 const &rhs) const
bool operator!=(Permutation4 const &rhs) const