votca 2024.1-dev
Loading...
Searching...
No Matches
gauss_legendre_quadrature.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#ifndef VOTCA_XTP_GAUSS_LEGENDRE_QUADRATURE_H
21#define VOTCA_XTP_GAUSS_LEGENDRE_QUADRATURE_H
22
25
26namespace votca {
27namespace xtp {
28
30
31 protected:
32 void FillPoints() final;
33 void FillAdaptedWeights() final;
34};
35
38 public:
39 double ScaledPoint(Index i) const final {
40 return 0.5 * (1.0 + points_(i)) / (1.0 - points_(i));
41 }
42 double ScaledWeight(Index i) const final {
43 double den = (1.0 - points_(i)) * (1.0 - points_(i));
44 return weights_(i) / den;
45 }
46
47 protected:
48 // The modified legendre method is suitable for integration limits a = 0 b =
49 // +infty. Here we have value1 and value2 because we split the original
50 // integral from -infty to +infty in two parts. Original legendre quadrature
51 // is meant for integral with integration limits of -1 and 1. To overcome
52 // this we use the transformation x' = 0.5 * (1+x/1-x)
53 bool UseSymmetry() const final { return true; }
54};
55
57 public:
58 double ScaledPoint(Index i) const final {
59 return std::tan(0.5 * votca::tools::conv::Pi * points_(i));
60 }
61
62 double ScaledWeight(Index i) const final {
63 const double halfpi = 0.5 * tools::conv::Pi;
64 double den = std::cos(halfpi * points_[i]) * std::cos(halfpi * points_[i]);
65 return weights_(i) * halfpi / den;
66 }
67
68 protected:
69 // This particular legendre quadrature is suitable for integration limits a
70 // = -infty b = +infty. Original Legendre quadrature is meant for
71 // integration limits -1 and +1. The change of variables is x' = tan (pi/2 *
72 // x). When x=-1 we have x'=-infty. When x=1 we have x'=+infty
73 bool UseSymmetry() const final { return false; }
74};
75
76} // namespace xtp
77} // namespace votca
78
79#endif // VOTCA_XTP_GAUSS_LEGENDRE_QUADRATURE_H
const double Pi
Definition constants.h:36
base class for all analysis tools
Definition basebead.h:33
Eigen::Index Index
Definition types.h:26