votca 2024.2-dev
Loading...
Searching...
No Matches
symmetric_matrix.h
Go to the documentation of this file.
1/*
2 * Copyright 2009-2020 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_SYMMETRIC_MATRIX_H
22#define VOTCA_XTP_SYMMETRIC_MATRIX_H
23
24// Standard includes
25#include <iostream>
26#include <vector>
27
28// Local VOTCA includes
29#include "eigen.h"
30
31namespace votca {
32namespace xtp {
33
34/*
35 * A symmetric matrix implementation for doubles, acces upper diagonal matrix
36 */
38 public:
39 Symmetric_Matrix() = default;
41 dimension = dim;
42 data.resize((dim + 1) * dim / 2);
43 }
44
45 Symmetric_Matrix(const Eigen::MatrixXd& full);
46
47 Index size() const { return dimension; }
48
49 double TraceofProd(const Symmetric_Matrix& a) const;
50
51 void AddtoEigenMatrix(Eigen::MatrixXd& full, double factor = 1.0) const;
52
54 Eigen::SelfAdjointView<Eigen::MatrixXd, Eigen::Upper>& upper,
55 double factor = 1.0) const;
56
57 Eigen::MatrixXd FullMatrix() const;
58 // returns a matrix where only the upper triangle part is filled, rest is set
59 // to zero
60 Eigen::MatrixXd UpperMatrix() const;
61
62 double& operator()(Index i, Index j) { return data[index(i, j)]; };
63
64 const double& operator()(Index i, Index j) const {
65 return data[index(i, j)];
66 };
67
68 friend std::ostream& operator<<(std::ostream& out, const Symmetric_Matrix& a);
69
70 private:
71 Index index(Index i, Index j) const;
72
73 std::vector<double> data;
75};
76
77} // namespace xtp
78} // namespace votca
79
80#endif // VOTCA_XTP_SYMMETRIC_MATRIX_H
Index index(Index i, Index j) const
void AddtoEigenUpperMatrix(Eigen::SelfAdjointView< Eigen::MatrixXd, Eigen::Upper > &upper, double factor=1.0) const
double TraceofProd(const Symmetric_Matrix &a) const
Eigen::MatrixXd FullMatrix() const
double & operator()(Index i, Index j)
std::vector< double > data
void AddtoEigenMatrix(Eigen::MatrixXd &full, double factor=1.0) const
friend std::ostream & operator<<(std::ostream &out, const Symmetric_Matrix &a)
Eigen::MatrixXd UpperMatrix() const
const double & operator()(Index i, Index j) const
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26