keyword
stringclasses
7 values
repo_name
stringlengths
8
98
file_path
stringlengths
4
244
file_extension
stringclasses
29 values
file_size
int64
0
84.1M
line_count
int64
0
1.6M
content
stringlengths
1
84.1M
language
stringclasses
14 values
2D
dean0x7d/pybinding
cppcore/include/Model.hpp
.hpp
3,994
117
#pragma once #include "system/Registry.hpp" #include "system/System.hpp" #include "system/Shape.hpp" #include "system/Symmetry.hpp" #include "system/StructureModifiers.hpp" #include "leads/Leads.hpp" #include "hamiltonian/Hamiltonian.hpp" #include "hamiltonian/HamiltonianModifiers.hpp" #include "utils/Chrono.hpp" #inc...
Unknown
2D
dean0x7d/pybinding
cppcore/include/utils/Chrono.hpp
.hpp
1,112
53
#pragma once #include <string> #include <chrono> #include <ostream> namespace cpb { /** High resolution timer (below 1 microsecond accuracy). */ class Chrono { public: Chrono() { tic(); }; void tic() { tic_time = std::chrono::high_resolution_clock::now(); } Chrono& toc() { elapsed ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/CompressedSublattices.hpp
.hpp
3,740
102
#pragma once #include "Lattice.hpp" namespace cpb { /** Stores the sublattice IDs for all sites in a system in a compressed format Since sublattices with the same ID are always arranges as consecutive elements, this data is easily compressed using RLE (run-length encoding). The same IDs are consecutive and appea...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/Symmetry.hpp
.hpp
1,706
54
#pragma once #include "detail/slice.hpp" #include "numeric/dense.hpp" #include <vector> namespace cpb { class Foundation; struct SymmetryArea { Index3D left, right, middle; /// Is this lattice site contained in the symmetry unit cell? bool contains(Index3D const& index) const; }; struct Translation { ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/Registry.hpp
.hpp
2,544
77
#pragma once #include "numeric/dense.hpp" #include "detail/opaque_alias.hpp" #include <string> #include <vector> #include <unordered_map> namespace cpb { // TODO: replace with proper string_view using string_view = std::string const&; /// Sublattice and hopping ID data types using SubID = detail::OpaqueIntegerAlias...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/HoppingBlocks.hpp
.hpp
5,479
146
#pragma once #include "Lattice.hpp" #include "numeric/dense.hpp" #include "numeric/sparse.hpp" namespace cpb { /// Alternative CSR mapping of hopping IDs using HoppingCSR = SparseMatrixX<storage_idx_t>; /** A simple row and column index pair */ struct COO { storage_idx_t row; storage_idx_t col; COO()...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/Shape.hpp
.hpp
2,216
85
#pragma once #include "numeric/dense.hpp" #include <vector> #include <functional> namespace cpb { /** Shape of the primitive unit cell */ class Primitive { public: Primitive(int a1 = 1, int a2 = 1, int a3 = 1); Index3D size; }; /** Shape defined by bounding vertices and `contains` function The boundin...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/System.hpp
.hpp
2,748
81
#pragma once #include "Lattice.hpp" #include "system/CompressedSublattices.hpp" #include "system/HoppingBlocks.hpp" #include "system/Registry.hpp" #include "numeric/dense.hpp" #include "numeric/sparse.hpp" #include <vector> #include <memory> namespace cpb { class Foundation; class FinalizedIndices; class Translatio...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/Foundation.hpp
.hpp
13,581
388
#pragma once #include "Lattice.hpp" #include "detail/slice.hpp" #include "numeric/dense.hpp" #include "support/cppfuture.hpp" namespace cpb { class Primitive; class Shape; class Site; class Foundation; namespace detail { /// Return the lower and upper bounds of the shape in lattice vector coordinates std::p...
Unknown
2D
dean0x7d/pybinding
cppcore/include/system/StructureModifiers.hpp
.hpp
5,700
158
#pragma once #include "CompressedSublattices.hpp" #include "HoppingBlocks.hpp" #include "numeric/dense.hpp" #include <vector> #include <algorithm> #include <memory> namespace cpb { class Foundation; struct System; /** Modify the state (valid or invalid) of lattice sites, e.g. to create vacancies */ class SiteSta...
Unknown
2D
dean0x7d/pybinding
cppcore/include/support/cppfuture.hpp
.hpp
1,229
51
#pragma once #include <memory> #include <type_traits> // helper functions for use until C++14 brings this into std namespace cpb { namespace std14 { template<class T, class... Args> std::unique_ptr<T> make_unique(Args&&... args) { return std::unique_ptr<T>(new T(std::forward<Args>(args)...)); } template<class T>...
Unknown
2D
dean0x7d/pybinding
cppcore/include/support/simd.hpp
.hpp
14,323
438
#pragma once #if defined(__AVX2__) # define SIMDPP_ARCH_X86_AVX2 #elif defined(__AVX__) # define SIMDPP_ARCH_X86_AVX #elif defined(__SSE3__) # define SIMDPP_ARCH_X86_SSE3 #elif defined(__SSE2__) || defined(_M_X64) || _M_IX86_FP == 2 # define SIMDPP_ARCH_X86_SSE2 #endif #if defined(__FMA__) || (defined(_MSC_VER) && de...
Unknown
2D
dean0x7d/pybinding
cppcore/include/support/format.hpp
.hpp
811
32
#pragma once #include <fmt/format.h> #include <fmt/ostream.h> namespace fmt { /** Convert number to string with SI suffix, e.g.: 14226 -> 14.2k, 5395984 -> 5.39M */ inline std::string with_suffix(double number) { struct Pair { double value; char const* suffix; }; static constexpr Pair ma...
Unknown
2D
dean0x7d/pybinding
cppcore/include/support/variant.hpp
.hpp
685
25
#pragma once #ifdef _MSC_VER // suppress 'static_visitor' deprecation warning # pragma warning(disable : 4996) #endif #include <mapbox/variant.hpp> namespace cpb { namespace var { using namespace mapbox::util; /// Variant of a container with real elements template<template<class> class... C> using real = var::varian...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Moments.hpp
.hpp
4,505
151
#pragma once #include "kpm/OptimizedHamiltonian.hpp" #include <mutex> namespace cpb { namespace kpm { using BatchData = var::complex<ArrayX, ArrayXX>; /** Collects moments in the form of simple expectation values: `mu_n = <r|Tn(H)|r>` where `bra == ket == r`. It's only compatible with the diagonal `calc_moments`...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/reconstruct.hpp
.hpp
6,134
146
#pragma once #include "kpm/Bounds.hpp" namespace cpb { namespace kpm { /// Reconstruct function `F` from the given moments and function arguments. /// `F` can be any of the function objects defined below: SpectralDensity, GreensFunction, etc. template<class F, class M, class... Args> auto reconstruct(M const& moments...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Stats.hpp
.hpp
1,513
48
#pragma once #include "utils/Chrono.hpp" #include "detail/config.hpp" #include "support/format.hpp" namespace cpb { namespace kpm { inline std::string format_report(std::string msg, Chrono const& time, bool shortform) { auto const fmt_str = shortform ? "{:s} [{}] " : "- {:<80s} | {}\n"; return fmt::format(fmt...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Bounds.hpp
.hpp
2,393
73
#pragma once #include "hamiltonian/Hamiltonian.hpp" #include "utils/Chrono.hpp" namespace cpb { namespace kpm { /** The KPM scaling factors `a` and `b` */ template<class real_t = double> struct Scale { static constexpr auto tolerance = 0.01f; ///< needed because the energy bounds are not precise real_t a = ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/calc_moments.hpp
.hpp
5,725
149
#pragma once namespace cpb { namespace kpm { namespace calc_moments { template<class...> struct void_type { using type = void; }; template<class... Ts> using void_t = typename void_type<Ts...>::type; template<class Collector, class = void> struct is_diagonal : std::false_type {}; template<class Collector> struct is...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Core.hpp
.hpp
3,086
93
#pragma once #include "Model.hpp" #include "hamiltonian/Hamiltonian.hpp" #include "kpm/Bounds.hpp" #include "kpm/Config.hpp" #include "kpm/OptimizedHamiltonian.hpp" #include "kpm/Starter.hpp" #include "kpm/Moments.hpp" #include "kpm/Stats.hpp" #include "utils/Chrono.hpp" namespace cpb { namespace kpm { /** Does th...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Starter.hpp
.hpp
4,187
121
#pragma once #include "kpm/OptimizedHamiltonian.hpp" #include "numeric/dense.hpp" #include "compute/detail.hpp" #include <mutex> namespace cpb { namespace kpm { /// Produce the r0 starter vector for the KPM procedure struct Starter { using Make = std::function<var::complex<VectorX> (var::scalar_tag)>; Make...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/OptimizedHamiltonian.hpp
.hpp
8,361
199
#pragma once #include "hamiltonian/Hamiltonian.hpp" #include "kpm/Bounds.hpp" #include "kpm/Config.hpp" #include "numeric/sparse.hpp" #include "numeric/ellmatrix.hpp" #include "support/variant.hpp" #include "utils/Chrono.hpp" #include "detail/macros.hpp" namespace cpb { namespace kpm { /** Source and destination ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Kernel.hpp
.hpp
3,493
91
#pragma once #include "numeric/dense.hpp" namespace cpb { namespace kpm { /// Moment calculations at higher optimization levels require specific rounding. /// `n - 2` considers only moments in the main KPM loop. Divisible by 4 because /// that is the strictest requirement imposed by `opt_size_and_interleaved`. inline...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/Config.hpp
.hpp
988
35
#pragma once #include "kpm/Kernel.hpp" namespace cpb { namespace kpm { /// Sparse matrix format for the optimized Hamiltonian enum class MatrixFormat { CSR, ELL }; /** Algorithm selection, see the corresponding functions in `calc_moments.hpp` */ struct AlgorithmConfig { bool optimal_size; bool interleaved;...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/default/collectors.hpp
.hpp
4,120
132
#pragma once #include "kpm/OptimizedHamiltonian.hpp" #include "detail/macros.hpp" #include "support/simd.hpp" namespace cpb { namespace kpm { template<class scalar_t> class DiagonalCollector { public: using Vector = VectorX<scalar_t>; using VectorRef = Eigen::Ref<Vector>; ArrayX<scalar_t> moments; s...
Unknown
2D
dean0x7d/pybinding
cppcore/include/kpm/default/Compute.hpp
.hpp
818
30
#pragma once #include "kpm/Core.hpp" namespace cpb { namespace kpm { /** Default CPU implementation for computing KPM moments, see `Core` */ class DefaultCompute : public Compute::Interface { public: using ProgressCallback = std::function<void (idx_t delta, idx_t total)>; DefaultCompute(idx_t num_threads =...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/constant.hpp
.hpp
685
22
#pragma once #include <complex> namespace cpb { namespace constant { // imaginary one constexpr std::complex<float> i1(0, 1); // the omnipresent pi constexpr float pi = 3.14159265358979323846f; // electron charge [C] constexpr float e = 1.602e-19f; // reduced Planck constant [eV*s] cons...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/arrayref.hpp
.hpp
11,030
253
#pragma once #include "detail/typelist.hpp" #include "support/cppfuture.hpp" #include "numeric/traits.hpp" #include <algorithm> #include <numeric> #include <stdexcept> #include <array> namespace cpb { namespace num { /// Array scalar type enum class Tag : std::int8_t {f32, cf32, f64, cf64, b, i8, i16, i32, i64, u8, ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/dense.hpp
.hpp
12,283
361
#pragma once #include "detail/config.hpp" #include "numeric/traits.hpp" #include "numeric/arrayref.hpp" #include <Eigen/Core> #include <algorithm> #include <numeric> #include <vector> namespace cpb { // add common math functions to the global namespace using std::abs; using std::exp; using std::pow; using std::sqrt...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/traits.hpp
.hpp
3,622
117
#pragma once #include <complex> #include <string> #include <type_traits> #include <limits> namespace cpb { namespace num { namespace detail { template<class T> struct complex_traits { static_assert(std::is_arithmetic<T>::value, ""); using real_t = T; using complex_t = std::complex<T>;...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/sparseref.hpp
.hpp
4,029
133
#pragma once #include "detail/config.hpp" #include "numeric/arrayref.hpp" namespace cpb { namespace num { namespace detail { /** Reference to CSR matrix of any type */ struct BasicCsrConstRef { int const rows; int const cols; int const nnz; void const* const void_data...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/random.hpp
.hpp
1,481
53
#pragma once #include "numeric/dense.hpp" #include "support/cppfuture.hpp" #include <random> namespace cpb { namespace num { namespace detail { template<class Container> using get_element_t = get_real_t<std14::decay_t<decltype(std::declval<Container>()[0])>>; template<class scalar_t> using select_di...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/ellmatrix.hpp
.hpp
2,564
85
#pragma once #include "numeric/dense.hpp" #include "numeric/sparseref.hpp" namespace cpb { namespace num { /** ELLPACK format sparse matrix */ template<class scalar_t> class EllMatrix { using DataArray = ColMajorArrayXX<scalar_t>; using IndexArray = ColMajorArrayXX<storage_idx_t>; static constexpr auto ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/numeric/sparse.hpp
.hpp
6,234
194
#pragma once #include "detail/config.hpp" #include "numeric/sparseref.hpp" #include <Eigen/SparseCore> namespace cpb { template <class scalar_t> using SparseMatrixX = Eigen::SparseMatrix<scalar_t, Eigen::RowMajor, storage_idx_t>; using SparseMatrixXf = SparseMatrixX<float>; using SparseMatrixXcf = SparseMatrixX<std...
Unknown
2D
dean0x7d/pybinding
cppcore/include/hamiltonian/Hamiltonian.hpp
.hpp
6,535
179
#pragma once #include "hamiltonian/HamiltonianModifiers.hpp" #include "numeric/dense.hpp" #include "numeric/sparse.hpp" #include "numeric/traits.hpp" #include "numeric/constant.hpp" #include "support/variant.hpp" namespace cpb { /** Stores a CSR matrix variant of various scalar types: real or complex, single or do...
Unknown
2D
dean0x7d/pybinding
cppcore/include/hamiltonian/HamiltonianModifiers.hpp
.hpp
11,713
292
#pragma once #include "system/System.hpp" #include "numeric/dense.hpp" #include "numeric/sparse.hpp" #include "detail/macros.hpp" #include "detail/algorithm.hpp" #include <vector> #include <memory> namespace cpb { /** Thrown by a modifier if it determines that complex numbers must be returned even though it was ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/kernel_polynomial.hpp
.hpp
12,253
327
#pragma once #include "numeric/dense.hpp" #include "numeric/sparse.hpp" #include "numeric/ellmatrix.hpp" #include "numeric/traits.hpp" #include "compute/detail.hpp" #include "detail/macros.hpp" #include "support/simd.hpp" namespace cpb { namespace compute { /** KPM-specialized sparse matrix-vector multiplication (C...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/lanczos.hpp
.hpp
5,685
157
#pragma once #ifdef CPB_USE_MKL # include "mkl/lanczos.hpp" #else # include "eigen3/lanczos.hpp" #endif #include "numeric/sparse.hpp" #include "numeric/random.hpp" #include "compute/detail.hpp" #include "support/simd.hpp" namespace cpb { namespace compute { /** Lanczos-specialized sparse matrix-vector multiplicati...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/detail.hpp
.hpp
1,368
44
#pragma once #include "detail/macros.hpp" #include <complex> namespace cpb { namespace compute { namespace detail { /** These functions are needed because std::complex<T> operator* does additional checking which significantly slows down critical loops. This `mul` overload does a raw multiplication where the user ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/mkl/lanczos.hpp
.hpp
763
24
#pragma once #include "numeric/dense.hpp" #include "compute/mkl/wrapper.hpp" namespace cpb { namespace compute { template<class Derived, class scalar_t = typename Derived::Scalar> inline ArrayX<scalar_t> tridiagonal_eigenvalues(DenseBase<Derived> const& alpha, DenseBase...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/mkl/wrapper.hpp
.hpp
2,847
58
#pragma once #include <mkl.h> #include <complex> namespace cpb { namespace mkl { namespace detail { template<class scalar_t> struct typemap; template<> struct typemap<float> { using type = float; }; template<> struct typemap<double> { using type = double; }; template<> struct typemap<std::complex<floa...
Unknown
2D
dean0x7d/pybinding
cppcore/include/compute/eigen3/lanczos.hpp
.hpp
2,873
93
#pragma once #include "numeric/dense.hpp" #include <Eigen/Jacobi> namespace cpb { namespace compute { namespace detail { template<class real_t> static void tridiagonal_qr_step(real_t* diag, real_t* subdiag, int start, int end) { auto td = (diag[end-1] - diag[end]) * real_t(0.5); auto e = subdi...
Unknown
2D
dean0x7d/pybinding
cppcore/include/solver/FEAST.hpp
.hpp
3,880
98
#pragma once #include "detail/config.hpp" #ifdef CPB_USE_FEAST #include "solver/Solver.hpp" namespace cpb { struct FEASTConfig { // required user config double energy_min = 0; ///< lowest eigenvalue double energy_max = 0; ///< highest eigenvalue int initial_size_guess = 0; ///< initial user guess for...
Unknown
2D
dean0x7d/pybinding
cppcore/include/solver/Solver.hpp
.hpp
2,019
74
#pragma once #include "Model.hpp" #include "hamiltonian/Hamiltonian.hpp" #include "utils/Chrono.hpp" #include "numeric/dense.hpp" #include "detail/strategy.hpp" #include <memory> namespace cpb { /** Abstract base class for an eigensolver */ class SolverStrategy { public: virtual ~SolverStrategy() = default; ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/opaque_alias.hpp
.hpp
1,530
45
#pragma once #include "detail/config.hpp" #include "support/cppfuture.hpp" namespace cpb { namespace detail { /** Type-safe integer alias */ template<class Tag, class T = storage_idx_t> class OpaqueIntegerAlias { using Self = OpaqueIntegerAlias; // Don't create duplicate constructors static constexpr a...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/strategy.hpp
.hpp
1,619
49
#pragma once #include "hamiltonian/Hamiltonian.hpp" #include "support/cppfuture.hpp" namespace cpb { namespace detail { /** Function object which creates a new Strategy with the appropriate scalar type for the given Model BaseStrategy is the abstract base, to which a pointer will be returned. Strategy<scalar_t> m...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/macros.hpp
.hpp
1,498
39
#pragma once #define CPB_EXTERN_TEMPLATE_CLASS(T) \ extern template class T<float>; \ extern template class T<std::complex<float>>; \ extern template class T<double>; \ extern template class T<std::complex<double>>; #define CPB_INSTANTIATE_TEMPLATE_CLASS(T) \ temp...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/thread.hpp
.hpp
5,172
204
#pragma once #include <thread> #include <queue> #include <condition_variable> namespace cpb { namespace detail { template<class T> class Queue { public: struct Maybe { Maybe() = default; Maybe(T&& value) : value(std::move(value)), is_valid(true) {} operator bool() { return is_valid; } ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/sugar.hpp
.hpp
590
25
#pragma once #include <initializer_list> namespace cpb { namespace detail { /// Prevents unused variable warnings when evaluating variadic parameter packs template<class... Ts> void eval_unordered(Ts&&...) {} template<class T> void eval_ordered(std::initializer_list<T>) {} template<class It1, class It2> struct range...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/algorithm.hpp
.hpp
1,583
55
#pragma once #include "detail/config.hpp" #include <algorithm> namespace cpb { /** Slice a Vector into pieces of `slice_size` */ template<class Vector> class Sliced { struct Iterator { using Self = Iterator; using iterator_category = std::input_iterator_tag; using difference_type = std:...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/slice.hpp
.hpp
1,918
62
#pragma once #include <algorithm> #include <numeric> namespace cpb { /** Holds the start and end index of an array slice in 1 dimension */ struct SliceIndex { int start; int end; /// Entire array dimension SliceIndex() : start(0), end(-1) {} /// Single index -> intentionally implicit so that `a...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/config.hpp
.hpp
534
18
#pragma once #include <cstddef> #ifdef CPB_USE_MKL #define EIGEN_USE_MKL_ALL #define CPB_USE_FEAST #endif #define EIGEN_DONT_PARALLELIZE // disable Eigen's internal multi-threading (doesn't do much anyway) #define EIGEN_MAX_ALIGN_BYTES 32 // always use AVX alignment #define EIGEN_DEFAULT_DENSE_INDEX_TYPE std::ptrdiff...
Unknown
2D
dean0x7d/pybinding
cppcore/include/detail/typelist.hpp
.hpp
2,205
87
#pragma once #include <type_traits> namespace cpb { template<class...> struct TypeList {}; namespace tl { template<class List1, class List2> struct ConcatImpl; template<class List1, class List2> using Concat = typename ConcatImpl<List1, List2>::type; template<class... Ts1, class... Ts2> struct ConcatImpl<TypeList...
Unknown
2D
dean0x7d/pybinding
cppcore/include/leads/Leads.hpp
.hpp
2,011
62
#pragma once #include "leads/Spec.hpp" #include "leads/Structure.hpp" #include "leads/HamiltonianPair.hpp" namespace cpb { /** Full description of a single lead */ class Lead { leads::Spec specification; leads::Structure structure; leads::HamiltonianPair hamiltonian; public: Lead(leads::Spec const&...
Unknown
2D
dean0x7d/pybinding
cppcore/include/leads/HamiltonianPair.hpp
.hpp
2,508
68
#pragma once #include "hamiltonian/Hamiltonian.hpp" namespace cpb { namespace leads { namespace detail { template<class scalar_t> Hamiltonian make_h0(System const& lead_system, Lattice const& lattice, HamiltonianModifiers const& modifiers) { auto h0 = std::make_shared<SparseMat...
Unknown
2D
dean0x7d/pybinding
cppcore/include/leads/Structure.hpp
.hpp
836
30
#pragma once #include "leads/Spec.hpp" #include "system/System.hpp" #include <vector> namespace cpb { namespace leads { /** Lead structural information: sites, hoppings and connection to main system */ struct Structure { std::vector<int> indices; ///< map from lead Hamiltonian indices to main system indices ...
Unknown
2D
dean0x7d/pybinding
cppcore/include/leads/Spec.hpp
.hpp
1,616
50
#pragma once #include "system/Shape.hpp" #include "detail/slice.hpp" #include "numeric/dense.hpp" namespace cpb { class Foundation; namespace leads { /** Lead specification The direction parameter needs to be one of: 1, 2, 3, -1, -2, -3. The number indicates the lattice vector along which the lead is placed. I...
Unknown
2D
dean0x7d/pybinding
cppcore/cuda/thrust.hpp
.hpp
307
17
#pragma once #ifdef __clang__ # pragma clang diagnostic push # pragma clang diagnostic ignored "-Wall" # pragma clang diagnostic ignored "-Wunused-parameter" #endif #include <thrust/host_vector.h> #include <thrust/complex.h> #ifdef __clang__ # pragma clang diagnostic pop #endif namespace thr = thrust;
Unknown
2D
dean0x7d/pybinding
cppcore/cuda/kpm/calc_moments.hpp
.hpp
1,491
44
#pragma once #include "kpm/OptimizedSizes.hpp" #include "detail/macros.hpp" #include "numeric/sparseref.hpp" #include "cuda/thrust.hpp" namespace cpb { namespace cuda { /** The Cuda functions must be defined only in nvcc-compiled translation units, but the declarations need to be visible to non-Cuda code as well. ...
Unknown
2D
dean0x7d/pybinding
cppcore/src/Lattice.cpp
.cpp
12,652
332
#include "Lattice.hpp" #include <Eigen/Dense> // for `colPivHouseholderQr()` #include <support/format.hpp> using namespace fmt::literals; namespace cpb { namespace { /// Visit all hopping terms in all families template<class F> void for_each_term(Lattice::Hoppings const& hoppings, F lambda) { f...
C++
2D
dean0x7d/pybinding
cppcore/src/KPM.cpp
.cpp
5,880
151
#include "KPM.hpp" using namespace fmt::literals; namespace cpb { KPM::KPM(Model const& model, kpm::Compute const& compute, kpm::Config const& config) : model(model.eval()), core(kpm::Core(model.hamiltonian(), compute, config)) {} void KPM::set_model(Model const& new_model) { model = new_model; core.set...
C++
2D
dean0x7d/pybinding
cppcore/src/Model.cpp
.cpp
6,388
218
#include "Model.hpp" #include "system/Foundation.hpp" #include "support/format.hpp" namespace cpb { Model::Model(Lattice const& lattice) : lattice(lattice), site_registry(lattice.site_registry()), hopping_registry(lattice.hopping_registry()) {} void Model::add(Primitive new_primitive) { primitiv...
C++
2D
dean0x7d/pybinding
cppcore/src/utils/Chrono.cpp
.cpp
1,583
43
#include "utils/Chrono.hpp" #include "support/format.hpp" using namespace std::chrono; using namespace cpb; std::string Chrono::str() const { auto ret = std::string{}; if (elapsed < milliseconds{1}) { ret = fmt::format("{:.2f}ms", duration_cast<duration<float, std::milli>>(elapsed).count()); } els...
C++
2D
dean0x7d/pybinding
cppcore/src/system/StructureModifiers.cpp
.cpp
2,160
70
#include "system/StructureModifiers.hpp" #include "system/Foundation.hpp" #include "system/System.hpp" namespace cpb { void apply(SiteStateModifier const& m, Foundation& f) { for (auto const& pair : f.get_lattice().get_sublattices()) { auto slice = f[pair.second.unique_id]; m.apply(slice.get_stat...
C++
2D
dean0x7d/pybinding
cppcore/src/system/Registry.cpp
.cpp
4,282
145
#include "system/Registry.hpp" #include "support/format.hpp" using namespace fmt::literals; namespace cpb { namespace { void check_energy(SiteRegistry const&, MatrixXcd const& energy) { detail::check_onsite_energy(energy); } void check_energy(HoppingRegistry const&, MatrixXcd const& energy) { detail::check...
C++
2D
dean0x7d/pybinding
cppcore/src/system/Symmetry.cpp
.cpp
3,939
124
#include "system/Symmetry.hpp" #include "system/Foundation.hpp" namespace cpb { TranslationalSymmetry::TranslationalSymmetry(float a1, float a2, float a3) : length(a1, a2, a3), enabled_directions(a1 >= 0, a2 >= 0, a3 >= 0) {} bool SymmetryArea::contains(Index3D const& index) const { return all_of(left.array(...
C++
2D
dean0x7d/pybinding
cppcore/src/system/Shape.cpp
.cpp
4,293
118
#include "system/Shape.hpp" namespace cpb { Primitive::Primitive(int a1, int a2, int a3) : size(a1, a2, a3) { if (any_of(size.array() <= 0)) { throw std::logic_error("Primitive: The size must be at least 1 in every direction."); } } Shape::Shape(Vertices const& vertices, Contains const& contains) ...
C++
2D
dean0x7d/pybinding
cppcore/src/system/HoppingBlocks.cpp
.cpp
3,311
108
#include "system/HoppingBlocks.hpp" namespace cpb { HoppingBlocks::HoppingBlocks(idx_t num_sites, SerializedBlocks const& data, NameMap name_map) : num_sites(num_sites), name_map(std::move(name_map)) { blocks.reserve(data.size()); for (auto const& pair : data) { auto const size = pair.first.size()...
C++
2D
dean0x7d/pybinding
cppcore/src/system/CompressedSublattices.cpp
.cpp
3,682
106
#include "system/CompressedSublattices.hpp" namespace cpb { CompressedSublattices::CompressedSublattices(ArrayXi const& alias_ids, ArrayXi const& site_counts, ArrayXi const& orbital_counts) : data(alias_ids.size()) { for (auto i = size_t{0}; i < data.size(); ++i) {...
C++
2D
dean0x7d/pybinding
cppcore/src/system/System.cpp
.cpp
6,450
178
#include "system/System.hpp" #include "system/Foundation.hpp" #include "system/Symmetry.hpp" namespace cpb { idx_t System::hamiltonian_size() const { auto result = idx_t{0}; for (auto const& sub : compressed_sublattices) { result += sub.ham_size(); } return result; } idx_t System::hamiltonia...
C++
2D
dean0x7d/pybinding
cppcore/src/system/Foundation.cpp
.cpp
6,401
167
#include "system/Foundation.hpp" #include "system/Shape.hpp" namespace cpb { namespace detail { std::pair<Index3D, Index3D> find_bounds(Shape const& shape, Lattice const& lattice) { Array3i lower_bound = Array3i::Constant(std::numeric_limits<int>::max()); Array3i upper_bound = Array3i::Constant(std::numeric_l...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Stats.cpp
.cpp
2,777
72
#include "kpm/Stats.hpp" #include "kpm/Config.hpp" #include "kpm/OptimizedHamiltonian.hpp" namespace cpb { namespace kpm { namespace { std::string hamiltonian_report(Stats const& s, bool shortform) { auto const nnz_diff = static_cast<double>(s.nnz - s.opt_nnz); auto const percent_removed = 100.0 ...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Core.cpp
.cpp
6,991
159
#include "kpm/Core.hpp" #include "kpm/reconstruct.hpp" namespace cpb { namespace kpm { namespace { Bounds reset_bounds(Hamiltonian const& h, Config const& config) { if (config.min_energy == config.max_energy) { return {h, config.lanczos_precision}; // will be automatically computed } ...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Kernel.cpp
.cpp
1,831
52
#include "kpm/Kernel.hpp" #include "numeric/constant.hpp" namespace cpb { namespace kpm { Kernel jackson_kernel() { return { [](idx_t num_moments) -> ArrayXd { auto const N = static_cast<double>(num_moments); auto const Np = N + 1; auto const ns = make_integer_range<dou...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Starter.cpp
.cpp
2,804
100
#include "kpm/Starter.hpp" #include "numeric/random.hpp" namespace cpb { namespace kpm { namespace { struct ConstantStarter { OptimizedHamiltonian const& oh; VectorXcd const& alpha; ConstantStarter(OptimizedHamiltonian const& oh, VectorXcd const& alpha) : oh(oh), alpha(alpha) {} var::compl...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Moments.cpp
.cpp
4,673
159
#include "kpm/Moments.hpp" namespace cpb { namespace kpm { namespace { struct BatchAccumulatorImpl { BatchData& var_result; idx_t idx; idx_t num_vectors; idx_t& count; template<class scalar_t> void operator()(ArrayX<scalar_t> const& a) { if (count == 0) { var_result = a; ...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/Bounds.cpp
.cpp
1,113
42
#include "kpm/Bounds.hpp" #include "kpm/Stats.hpp" #include "compute/lanczos.hpp" namespace cpb { namespace kpm { namespace { struct MinMaxEigenvalues { double precision_percent; template<class scalar_t> compute::LanczosBounds operator()(SparseMatrixRC<scalar_t> const& ph) const { return comput...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/OptimizedHamiltonian.cpp
.cpp
8,861
243
#include "kpm/OptimizedHamiltonian.hpp" namespace cpb { namespace kpm { SliceMap::SliceMap(std::vector<storage_idx_t> indices, Indices const& optimized_idx) : data(std::move(indices)) { auto find_offset = [&](ArrayXi const& idx) { assert(idx.size() != 0); auto const max_index = *std::max_eleme...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/default/collectors.cpp
.cpp
3,879
115
#include "kpm/default/collectors.hpp" namespace cpb { namespace kpm { template<class scalar_t> void DiagonalCollector<scalar_t>::initial(VectorRef r0, VectorRef r1) { m0 = moments[0] = r0.squaredNorm() * scalar_t{0.5}; m1 = moments[1] = r1.dot(r0); } template<class scalar_t> void DiagonalCollector<scalar_t>:...
C++
2D
dean0x7d/pybinding
cppcore/src/kpm/default/Compute.cpp
.cpp
4,757
147
#include "kpm/default/Compute.hpp" #include "kpm/default/collectors.hpp" #include "compute/kernel_polynomial.hpp" #include "kpm/calc_moments.hpp" #include "detail/thread.hpp" namespace cpb { namespace kpm { namespace { template<class Matrix> struct SelectAlgorithm { using scalar_t = typename Matrix::Scalar; ...
C++
2D
dean0x7d/pybinding
cppcore/src/hamiltonian/Hamiltonian.cpp
.cpp
1,497
63
#include "hamiltonian/Hamiltonian.hpp" namespace cpb { namespace { struct IsValid { template<class scalar_t> bool operator()(SparseMatrixRC<scalar_t> const& p) const { return p != nullptr; } }; struct Reset { template<class scalar_t> void operator()(SparseMatrixRC<scalar_t>& p) const { p.reset(); } }...
C++
2D
dean0x7d/pybinding
cppcore/src/hamiltonian/HamiltonianModifiers.cpp
.cpp
951
31
#include "hamiltonian/HamiltonianModifiers.hpp" namespace cpb { bool HamiltonianModifiers::any_complex() const { const auto complex_potential = std::any_of( onsite.begin(), onsite.end(), [](OnsiteModifier const& o) { return o.is_complex; } ); auto const complex_hoppings = std::any_of( hopp...
C++
2D
dean0x7d/pybinding
cppcore/src/solver/Solver.cpp
.cpp
3,095
104
#include "solver/Solver.hpp" namespace cpb { namespace compute { struct CalcDOS { ArrayXf const& target_energies; float broadening; template<class Array> ArrayXd operator()(Array En) { auto const scale = 1 / (broadening * sqrt(2 * constant::pi)); auto const constant = -0.5f / pow(broa...
C++
2D
dean0x7d/pybinding
cppcore/src/solver/FEAST.cpp
.cpp
8,997
250
#include "solver/FEAST.hpp" #ifdef CPB_USE_FEAST # include "support/format.hpp" # include "compute/mkl/wrapper.hpp" using namespace fmt::literals; using namespace cpb; template<class scalar_t> void FEAST<scalar_t>::solve() { // size of the matrix config.system_size = hamiltonian->rows(); // reset info fl...
C++
2D
dean0x7d/pybinding
cppcore/src/leads/Leads.cpp
.cpp
955
42
#include "leads/Leads.hpp" namespace cpb { void Leads::create_attachment_area(Foundation& foundation) const { for (auto const& spec : specs) { leads::create_attachment_area(foundation, spec); } } void Leads::make_structure(Foundation const& foundation) { if (!structures.empty()) { return;...
C++
2D
dean0x7d/pybinding
cppcore/src/leads/Structure.cpp
.cpp
3,003
81
#include "leads/Structure.hpp" #include "system/Foundation.hpp" namespace cpb { namespace leads { Structure::Structure(Foundation const& foundation, Spec const& lead) : system(foundation.get_lattice().site_registry(), foundation.get_lattice().hopping_registry()) { auto const& lattice = foundation...
C++
2D
dean0x7d/pybinding
cppcore/src/leads/Spec.cpp
.cpp
3,670
106
#include "leads/Spec.hpp" #include "system/Foundation.hpp" namespace cpb { namespace leads { Spec::Spec(int direction, Shape const& shape) : axis(abs(direction) - 1), sign(direction != 0 ? direction / abs(direction) : 0), shape(shape) {} void create_attachment_area(Foundation& foundation, Spec const&...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_leads.cpp
.cpp
1,446
41
#include <catch.hpp> #include "fixtures.hpp" using namespace cpb; /// Return the data array of a Hamiltonian CSR matrix template<class scalar_t = float> ArrayXf matrix_data(Hamiltonian const& h) { auto const matrix = ham::get_reference<scalar_t>(h); return Eigen::Map<ArrayXf const>(matrix.valuePtr(), matrix.n...
C++
2D
dean0x7d/pybinding
cppcore/tests/catch.cpp
.cpp
47
3
#define CATCH_CONFIG_MAIN #include <catch.hpp>
C++
2D
dean0x7d/pybinding
cppcore/tests/test_shape.cpp
.cpp
1,770
54
#include <catch.hpp> #include "fixtures.hpp" using namespace cpb; TEST_CASE("Primitive") { REQUIRE_THROWS_WITH(Model(lattice::square(), Primitive(2, 2, 2)), Catch::Contains("more dimensions than the lattice")); } TEST_CASE("FreeformShape", "[shape]") { auto const contains = [](Cartesi...
C++
2D
dean0x7d/pybinding
cppcore/tests/fixtures.cpp
.cpp
7,718
246
#include "fixtures.hpp" using namespace cpb; namespace lattice { Lattice square(float a, float t) { auto lattice = Lattice({a, 0, 0}, {0, a, 0}); lattice.add_sublattice("A", {0, 0, 0}, 4 * t); lattice.register_hopping_energy("-t", -t); lattice.add_hopping({0, 1, 0}, "A", "A", "-t"); lattice.add_...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_system.cpp
.cpp
6,777
185
#include <catch.hpp> #include "fixtures.hpp" using namespace cpb; TEST_CASE("CompressedSublattices") { auto inject = [](CompressedSublattices& cs, idx_t size, SiteID id, idx_t norb) { for (auto i = 0; i < size; ++i) { cs.add(id, norb); } }; constexpr auto size = 30; auto c...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_kpm.cpp
.cpp
14,572
321
#include <catch.hpp> #include "fixtures.hpp" #include "KPM.hpp" using namespace cpb; Model make_test_model(bool is_double = false, bool is_complex = false) { auto model = Model(graphene::monolayer(), shape::rectangle(0.6f, 0.8f), field::constant_potential(1)); if (is_double) { m...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_numeric.cpp
.cpp
2,850
86
#include <catch.hpp> #include "numeric/dense.hpp" using namespace cpb; struct ArrayRefTestOp { template<class Vector> num::Tag operator()(Vector v) const { v[3] = 0; return num::detail::get_tag<typename Vector::Scalar>(); } }; TEST_CASE("ArrayRef and match", "[arrayref]") { Eigen::Vec...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_detail.cpp
.cpp
2,085
59
#include <catch.hpp> #include <complex> #include "Model.hpp" #include "detail/algorithm.hpp" using namespace cpb; namespace static_test_typelist { using List = TypeList<float, double, std::complex<float>, std::complex<double>>; static_assert(tl::AnyOf<List, float>::value, ""); static_assert(!tl::AnyOf<Li...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_lattice.cpp
.cpp
10,139
229
#include <catch.hpp> #include "Model.hpp" using namespace cpb; TEST_CASE("Lattice") { auto lattice = Lattice({1, 0, 0}, {0, 1, 0}); REQUIRE(lattice.ndim() == 2); REQUIRE(lattice.get_vectors().capacity() == 2); REQUIRE(lattice.max_hoppings() == 0); SECTION("Add sublattices") { REQUIRE_THRO...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_modifiers.cpp
.cpp
10,490
295
#include <catch.hpp> #include "fixtures.hpp" using namespace cpb; TEST_CASE("SiteStateModifier") { auto model = Model(lattice::square_2atom(), Primitive(2)); REQUIRE(model.system()->num_sites() == 4); auto count = std::unordered_map<std::string, idx_t>(); auto remove_site = [&](Eigen::Ref<ArrayX<boo...
C++
2D
dean0x7d/pybinding
cppcore/tests/test_compute.cpp
.cpp
5,711
163
#include <catch.hpp> #include "compute/lanczos.hpp" #include "compute/kernel_polynomial.hpp" #include "fixtures.hpp" using namespace cpb; TEST_CASE("Lanczos", "[lanczos]") { auto const model = Model(graphene::monolayer(), Primitive(5, 5), TranslationalSymmetry(1, 1)); auto const&...
C++
2D
dean0x7d/pybinding
cppcore/tests/fixtures.hpp
.hpp
1,144
48
#pragma once #include "Model.hpp" namespace lattice { cpb::Lattice square(float a = 1.f, float t = 1.f); cpb::Lattice square_2atom(float a = 1.f, float t1 = 1.f, float t2 = 2.f); cpb::Lattice square_multiorbital(); cpb::Lattice checkerboard_multiorbital(); cpb::Lattice hexagonal_complex(); } // namespace lattice na...
Unknown
2D
dean0x7d/pybinding
pybinding/__about__.py
.py
359
11
"""Package for numerical tight-binding calculations in solid state physics""" __title__ = "pybinding" __version__ = "0.9.6.dev" __summary__ = "Package for tight-binding calculations" __url__ = "https://github.com/dean0x7d/pybinding" __author__ = "Dean Moldovan" __copyright__ = "2015-2020, " + __author__ __email__ = "d...
Python