GQCP
Loading...
Searching...
No Matches
LeviCivitaTensor.hpp
Go to the documentation of this file.
1// This file is part of GQCG-GQCP.
2//
3// Copyright (C) 2017-2020 the GQCG developers
4//
5// GQCG-GQCP is free software: you can redistribute it and/or modify
6// it under the terms of the GNU Lesser General Public License as published by
7// the Free Software Foundation, either version 3 of the License, or
8// (at your option) any later version.
9//
10// GQCG-GQCP is distributed in the hope that it will be useful,
11// but WITHOUT ANY WARRANTY; without even the implied warranty of
12// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
13// GNU Lesser General Public License for more details.
14//
15// You should have received a copy of the GNU Lesser General Public License
16// along with GQCG-GQCP. If not, see <http://www.gnu.org/licenses/>.
17
18#pragma once
19
20
22
23#include <unsupported/Eigen/CXX11/TensorSymmetry>
24
25
26namespace GQCP {
27
28
34template <typename _Scalar>
36public:
37 // The scalar type of one of the elements of the tensor.
38 using Scalar = _Scalar;
39
40private:
41 // The values of the Levi-Civita tensor.
42 Tensor<Scalar, 3> epsilon;
43
44public:
45 /*
46 * MARK: Constructors
47 */
48
53
54 // Initialize a zero tensor.
55 this->epsilon = Tensor<Scalar, 3>(3, 3, 3);
56 this->epsilon.setZero();
57
58
59 // Construct the antisymmetries of the Levi-Civita tensor and set its elements.
60 Eigen::SGroup<Eigen::AntiSymmetry<0, 1>, Eigen::AntiSymmetry<1, 2>> symmetry;
61 symmetry(this->epsilon, 0, 1, 2) = 1.0;
62 }
63
64
65 /*
66 * MARK: Element access
67 */
68
78 Scalar operator()(const size_t i, const size_t j, const size_t k) const { return this->epsilon(i, j, k); }
79
88 size_t nonZeroIndex(const size_t i, const size_t j) const {
89
90 if (i == j) {
91 throw std::invalid_argument("LeviCivitaTensor::nonZeroIndex(const size_t, const size_t): The given indices cannot be equal.");
92 }
93
94 return 3 - (i + j);
95
96 }
97};
98
99
100} // namespace GQCP
Definition: LeviCivitaTensor.hpp:35
LeviCivitaTensor()
Definition: LeviCivitaTensor.hpp:52
Scalar operator()(const size_t i, const size_t j, const size_t k) const
Definition: LeviCivitaTensor.hpp:78
size_t nonZeroIndex(const size_t i, const size_t j) const
Definition: LeviCivitaTensor.hpp:88
_Scalar Scalar
Definition: LeviCivitaTensor.hpp:38
Definition: Tensor.hpp:46
Definition: BaseOneElectronIntegralBuffer.hpp:25