GQCP
Loading...
Searching...
No Matches
SimpleTransformation.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
25
26#include <unsupported/Eigen/MatrixFunctions>
27
28
29namespace GQCP {
30
31
32/*
33 * MARK: SimpleTransformation implementation
34 */
35
46template <typename _Scalar, typename _DerivedTransformation>
48 public BasisTransformable<_DerivedTransformation>,
49 public JacobiRotatable<_DerivedTransformation> {
50
51public:
52 // The scalar type used for a transformation coefficient: real or complex.
53 using Scalar = _Scalar;
54
55 // The type of the transformation that derives from this class, enabling CRTP and compile-time polymorphism.
56 using DerivedTransformation = _DerivedTransformation;
57
58 // The type of 'this'.
60
61 // The type of Jacobi rotation for which the Jacobi rotation should be defined.
63
64 // The type of the orbital rotation generators that is naturally associated with the derived transformation.
66
67
68protected:
69 // The transformation matrix that collects the expansion coefficients of the new basis (vectors) in the old basis as columns.
71
72
73public:
74 /*
75 * MARK: Constructors
76 */
77
84 T {T} {}
85
86
93 T {(-kappa.asMatrix()).exp()} {}
94
95
96 /*
97 * MARK: Named constructors
98 */
99
108 static DerivedTransformation FromJacobi(const JacobiRotation& jacobi_rotation, const size_t dim) {
109
110 // Create an identity transformation matrix and apply a Jacobi rotation.
112
113 return J.rotated(jacobi_rotation);
114 }
115
116
123
130
137
144
145
146 /*
147 * MARK: General information
148 */
149
153 size_t numberOfOrbitals() const { return this->matrix().dimension(); }
154
158 size_t dimension() const { return this->numberOfOrbitals(); }
159
160
161 /*
162 * MARK: Transformation matrix
163 */
164
168 const SquareMatrix<Scalar>& matrix() const { return this->T; }
169
170
171 /*
172 * MARK: Linear algebra
173 */
174
178 DerivedTransformation adjoint() const { return DerivedTransformation {this->matrix().adjoint()}; }
179
183 DerivedTransformation inverse() const { return DerivedTransformation {this->matrix().inverse()}; }
184
192 bool isUnitary(const double threshold = 1.0e-12) const { return this->matrix().isUnitary(threshold); }
193
194
195 /*
196 * MARK: Conforming to `BasisTransformable`
197 */
198
206 DerivedTransformation transformed(const DerivedTransformation& T) const override { return DerivedTransformation {this->matrix() * T.matrix()}; }
207
208 // Allow the `rotate` method from `BasisTransformable`, since there's also a `rotate` from `JacobiRotatable`.
210
211 // Allow the `rotated` method from `BasisTransformable`, since there's also a `rotated` from `JacobiRotatable`.
213
214
215 /*
216 * MARK: Conforming to JacobiRotatable
217 */
218
226 DerivedTransformation rotated(const JacobiRotationType& jacobi_rotation) const override {
227
228 const auto p = jacobi_rotation.p();
229 const auto q = jacobi_rotation.q();
230
231 // Create the matrix representation of a Jacobi rotation using Eigen's APIs.
232 // We're applying the Jacobi rotation as J = I * jacobi_rotation (cfr. B' = B T).
233 const auto eigen_jacobi_rotation = jacobi_rotation.Eigen();
234 auto result = this->matrix();
235 result.applyOnTheRight(p, q, eigen_jacobi_rotation);
236
237 return DerivedTransformation {result};
238 }
239
240 // Allow the `rotate` method from `JacobiRotatable`, since there's also a `rotate` from `BasisTransformable`.
242};
243
244
245/*
246 * MARK: BasisTransformableTraits
247 */
248
252template <typename Scalar, typename DerivedTransformation>
253struct BasisTransformableTraits<SimpleTransformation<Scalar, DerivedTransformation>> {
254
255 // The type of the transformation for which the basis transformation should be defined. A transformation matrix should naturally be transformable with itself.
256 using Transformation = DerivedTransformation;
257};
258
259
260/*
261 * MARK: JacobiRotatableTraits
262 */
263
269template <typename Scalar, typename DerivedTransformation>
270struct JacobiRotatableTraits<SimpleTransformation<Scalar, DerivedTransformation>> {
271
272 // The type of Jacobi rotation for which the Jacobi rotation should be defined.
274};
275
276
277} // namespace GQCP
Definition: BasisTransformable.hpp:50
void rotate(const Transformation &U)
Definition: BasisTransformable.hpp:107
Definition: JacobiRotatable.hpp:50
Definition: JacobiRotation.hpp:33
Eigen::JacobiRotation< double > Eigen() const
Definition: JacobiRotation.hpp:103
size_t p() const
Definition: JacobiRotation.hpp:88
size_t q() const
Definition: JacobiRotation.hpp:93
Definition: SimpleTransformation.hpp:49
DerivedTransformation adjoint() const
Definition: SimpleTransformation.hpp:178
size_t numberOfOrbitals() const
Definition: SimpleTransformation.hpp:153
typename OrbitalRotationGeneratorTraits< DerivedTransformation >::OrbitalRotationGenerators OrbitalRotationGeneratorType
Definition: SimpleTransformation.hpp:65
DerivedTransformation rotated(const JacobiRotationType &jacobi_rotation) const override
Definition: SimpleTransformation.hpp:226
_Scalar Scalar
Definition: SimpleTransformation.hpp:53
SimpleTransformation(const SquareMatrix< Scalar > &T)
Definition: SimpleTransformation.hpp:83
DerivedTransformation inverse() const
Definition: SimpleTransformation.hpp:183
static DerivedTransformation FromJacobi(const JacobiRotation &jacobi_rotation, const size_t dim)
Definition: SimpleTransformation.hpp:108
size_t dimension() const
Definition: SimpleTransformation.hpp:158
const SquareMatrix< Scalar > & matrix() const
Definition: SimpleTransformation.hpp:168
static DerivedTransformation Random(const size_t dim)
Definition: SimpleTransformation.hpp:129
bool isUnitary(const double threshold=1.0e-12) const
Definition: SimpleTransformation.hpp:192
DerivedTransformation transformed(const DerivedTransformation &T) const override
Definition: SimpleTransformation.hpp:206
_DerivedTransformation DerivedTransformation
Definition: SimpleTransformation.hpp:56
SimpleTransformation(const OrbitalRotationGeneratorType &kappa)
Definition: SimpleTransformation.hpp:92
SquareMatrix< Scalar > T
Definition: SimpleTransformation.hpp:70
static DerivedTransformation Zero(const size_t dim)
Definition: SimpleTransformation.hpp:143
static DerivedTransformation RandomUnitary(const size_t dim)
Definition: SimpleTransformation.hpp:136
static DerivedTransformation Identity(const size_t dim)
Definition: SimpleTransformation.hpp:122
Definition: SquareMatrix.hpp:39
size_t dimension() const
Definition: SquareMatrix.hpp:299
static Self Random(const size_t dim)
Definition: SquareMatrix.hpp:191
static Self RandomUnitary(const size_t dim)
Definition: SquareMatrix.hpp:216
static Self Identity(const size_t dim)
Definition: SquareMatrix.hpp:143
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
Definition: BaseOneElectronIntegralBuffer.hpp:25
DerivedTransformation Transformation
Definition: SimpleTransformation.hpp:256
Definition: BasisTransformable.hpp:37
Definition: JacobiRotatable.hpp:37
Definition: OrbitalRotationGeneratorTraits.hpp:28