votca 2026-dev
Loading...
Searching...
No Matches
screening_kernels.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2026 The VOTCA Development Team
3 * (http://www.votca.org)
4 *
5 * Licensed under the Apache License, Version 2.0 (the "License")
6 *
7 * You may not use this file except in compliance with the License.
8 * You may obtain a copy of the License at
9 *
10 * http://www.apache.org/licenses/LICENSE-2.0
11 *
12 * Unless required by applicable law or agreed to in writing, software
13 * distributed under the License is distributed on an "AS IS" BASIS,
14 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15 * See the License for the specific language governing permissions and
16 * limitations under the License.
17 *
18 */
19
20#pragma once
21#ifndef VOTCA_XTP_SCREENING_KERNELS_H
22#define VOTCA_XTP_SCREENING_KERNELS_H
23
24// Standard includes
25#include <functional>
26#include <optional>
27#include <string>
28
29// Local VOTCA includes
30#include "dfttimings.h"
31#include "eigen.h"
32
33namespace votca {
34namespace xtp {
35
44 public:
47 std::function<void(const Eigen::Ref<const Eigen::MatrixXd>&)>;
48 using RowsFn = std::function<void(Index m, const RowsVisitor& use)>;
50 using WeightsFn = std::function<void(Index m, Eigen::VectorXd& w)>;
51
53 static void setBatchMemory(double bytes) { batch_bytes_ = bytes; }
54
55 static Eigen::MatrixXd Compute(Index nblocks, Index ncols,
56 const WeightsFn& weights, const RowsFn& rows);
57
58 private:
59 static double batch_bytes_;
60};
61
65 Eigen::VectorXd values;
66 Eigen::MatrixXd vectors;
67};
68
69SymmetricEigenSystem SymmetricEigen(const Eigen::MatrixXd& A,
70 bool vectors = true);
71
77 public:
78 CholeskyFactor() = default;
79 explicit CholeskyFactor(const Eigen::MatrixXd& A);
80 void compute(const Eigen::MatrixXd& A);
81 bool ok() const { return ok_; }
82 const Eigen::MatrixXd& matrixL() const { return L_; }
84 Eigen::MatrixXd SolveL(const Eigen::MatrixXd& B) const;
86 Eigen::MatrixXd Solve(const Eigen::MatrixXd& B) const;
87
88 private:
89 Eigen::MatrixXd L_;
90 bool ok_ = false;
91};
92
95Eigen::MatrixXd InverseSPD(const Eigen::MatrixXd& A);
96
101 public:
102 OptionalTiming(DFTTimings* timings, const std::string& name) {
103 if (timings != nullptr && !OPENMP::InsideActiveParallelRegion()) {
104 scope_.emplace(*timings, name);
105 }
106 }
107
108 private:
109 std::optional<DFTTimings::Scope> scope_;
110};
111
112} // namespace xtp
113} // namespace votca
114
115#endif // VOTCA_XTP_SCREENING_KERNELS_H
void compute(const Eigen::MatrixXd &A)
Eigen::MatrixXd Solve(const Eigen::MatrixXd &B) const
A^-1 B.
Eigen::MatrixXd SolveL(const Eigen::MatrixXd &B) const
L^-1 B.
const Eigen::MatrixXd & matrixL() const
Wall-clock accounting for the parts of a DFT run.
Definition dfttimings.h:45
OptionalTiming(DFTTimings *timings, const std::string &name)
std::optional< DFTTimings::Scope > scope_
std::function< void(Index m, const RowsVisitor &use)> RowsFn
std::function< void(Index m, Eigen::VectorXd &w)> WeightsFn
Writes the weights of block m; their number is the number of rows.
std::function< void(const Eigen::Ref< const Eigen::MatrixXd > &)> RowsVisitor
Calls use(R_m); R_m may be a block of stored data or a temporary.
static void setBatchMemory(double bytes)
Bytes for the stacked rows of one batch of blocks.
static Eigen::MatrixXd Compute(Index nblocks, Index ncols, const WeightsFn &weights, const RowsFn &rows)
bool InsideActiveParallelRegion()
Definition eigen.h:153
SymmetricEigenSystem SymmetricEigen(const Eigen::MatrixXd &A, bool vectors=true)
With vectors = false only the eigenvalues are computed.
Eigen::MatrixXd InverseSPD(const Eigen::MatrixXd &A)
Provides a means for comparing floating point numbers.
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26