GQCP
Loading...
Searching...
No Matches
GTransformation.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
27namespace GQCP {
28
29
30/*
31 * MARK: GTransformation implementation
32 */
33
41template <typename _Scalar>
43 public SimpleTransformation<_Scalar, GTransformation<_Scalar>> {
44public:
45 // The scalar type used for a transformation coefficient: real or complex.
46 using Scalar = _Scalar;
47
48
49private:
50 // The number of alpha and beta orbitals.
52
53
54public:
55 /*
56 * MARK: Constructors
57 */
58
65 SimpleTransformation<_Scalar, GTransformation<_Scalar>>(T),
66 K {SpinResolved<size_t>::FromEqual(T.dimension() / 2)} {}
67
68
76 GTransformation(const SquareMatrix<Scalar>& T, const size_t K_alpha, const size_t K_beta) :
77 SimpleTransformation<_Scalar, GTransformation<_Scalar>>(T),
78 K {K_alpha, K_beta} {
79
80 if (T.dimension() != K_alpha + K_beta) {
81 throw std::invalid_argument("GTransformation(const SquareMatrix<Scalar>&, const size_t, const size_t): The given transformation matrix is not compatible with the number of given overbitals.");
82 }
83 }
84
85
86 /*
87 * MARK: Named constructors
88 */
89
98
99 const auto u_transformation = GQCP::UTransformation<Scalar>::FromRestricted(r_transformation);
100 return GTransformation<Scalar>::FromUnrestricted(u_transformation);
101 }
102
103
112
113 // The goal in this named constructor is to build up the general coefficient matrix (2K x 2K) from the unrestricted (K_sigma x K_sigma) ones.
114 const auto K_alpha = u_transformation.alpha().numberOfOrbitals();
115 const auto K_beta = u_transformation.beta().numberOfOrbitals();
116 const auto M = K_alpha + K_beta;
117
119
120 // alpha | 0
121 // 0 | beta
122 T_general.topLeftCorner(K_alpha, K_alpha) = u_transformation.alpha().matrix();
123 T_general.bottomRightCorner(K_beta, K_beta) = u_transformation.beta().matrix();
124
125 return GTransformation<Scalar> {T_general, K_alpha, K_beta};
126 }
127
128
132 static GTransformation<Scalar> Identity(const size_t K_alpha, const size_t K_beta) {
133
134 return GTransformation<Scalar> {SquareMatrix<Scalar>::Identity(K_alpha + K_beta), K_alpha, K_beta};
135 }
136
137
138 /*
139 * MARK: Components
140 */
141
145 MatrixX<Scalar> alpha() const { return this->matrix().topRows(this->K.alpha()); }
146
150 MatrixX<Scalar> beta() const { return this->matrix().bottomRows(this->K.beta()); }
151
157 MatrixX<Scalar> component(const Spin sigma) const {
158
159 switch (sigma) {
160 case Spin::alpha: {
161 return this->alpha();
162 break;
163 }
164
165 case Spin::beta: {
166 return this->beta();
167 break;
168 }
169 }
170 }
171};
172
173
174/*
175 * MARK: BasisTransformableTraits
176 */
177
181template <typename Scalar>
183
184 // The type of the transformation for which the basis transformation should be defined. A transformation matrix should naturally be transformable with itself.
186};
187
188
189/*
190 * MARK: JacobiRotatableTraits
191 */
192
196template <typename Scalar>
198
199 // The type of Jacobi rotation for which the Jacobi rotation should be defined.
201};
202
203
204/*
205 * MARK: OrbitalRotationGeneratorTraits
206 */
207
211template <typename Scalar>
213
214 // The type of orbital rotation generators associated with an `GTransformation`.
216};
217
218
219} // namespace GQCP
Definition: GOrbitalRotationGenerators.hpp:39
Definition: GTransformation.hpp:43
MatrixX< Scalar > component(const Spin sigma) const
Definition: GTransformation.hpp:157
static GTransformation< Scalar > FromRestricted(const RTransformation< Scalar > &r_transformation)
Definition: GTransformation.hpp:97
MatrixX< Scalar > beta() const
Definition: GTransformation.hpp:150
_Scalar Scalar
Definition: GTransformation.hpp:46
static GTransformation< Scalar > Identity(const size_t K_alpha, const size_t K_beta)
Definition: GTransformation.hpp:132
static GTransformation< Scalar > FromUnrestricted(const UTransformation< Scalar > &u_transformation)
Definition: GTransformation.hpp:111
MatrixX< Scalar > alpha() const
Definition: GTransformation.hpp:145
GTransformation(const SquareMatrix< Scalar > &T)
Definition: GTransformation.hpp:64
GTransformation(const SquareMatrix< Scalar > &T, const size_t K_alpha, const size_t K_beta)
Definition: GTransformation.hpp:76
Definition: JacobiRotation.hpp:33
Definition: Matrix.hpp:47
Definition: RTransformation.hpp:41
Definition: SimpleTransformation.hpp:49
size_t numberOfOrbitals() const
Definition: SimpleTransformation.hpp:153
size_t dimension() const
Definition: SimpleTransformation.hpp:158
const SquareMatrix< Scalar > & matrix() const
Definition: SimpleTransformation.hpp:168
SquareMatrix< Scalar > T
Definition: SimpleTransformation.hpp:70
const Of & beta() const
Definition: SpinResolvedBase.hpp:140
const Of & alpha() const
Definition: SpinResolvedBase.hpp:130
Definition: SpinResolved.hpp:34
Definition: SquareMatrix.hpp:39
size_t dimension() const
Definition: SquareMatrix.hpp:299
static Self Identity(const size_t dim)
Definition: SquareMatrix.hpp:143
static Self Zero(const size_t dim)
Definition: SquareMatrix.hpp:289
Definition: UTransformation.hpp:46
static UTransformation< Scalar > FromRestricted(const RTransformation< Scalar > &T)
Definition: UTransformation.hpp:81
Definition: BaseOneElectronIntegralBuffer.hpp:25
Spin
Definition: Spin.hpp:27
@ beta
Definition: Spin.hpp:29
@ alpha
Definition: Spin.hpp:28
Definition: BasisTransformable.hpp:37
Definition: JacobiRotatable.hpp:37
Definition: OrbitalRotationGeneratorTraits.hpp:28