ergo
template_blas_basicmath.h
Go to the documentation of this file.
1 /* Ergo, version 3.7, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2018 Elias Rudberg, Emanuel H. Rubensson, Pawel Salek,
4  * and Anastasia Kruchinina.
5  *
6  * This program is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation, either version 3 of the License, or
9  * (at your option) any later version.
10  *
11  * This program is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with this program. If not, see <http://www.gnu.org/licenses/>.
18  *
19  * Primary academic reference:
20  * Ergo: An open-source program for linear-scaling electronic structure
21  * calculations,
22  * Elias Rudberg, Emanuel H. Rubensson, Pawel Salek, and Anastasia
23  * Kruchinina,
24  * SoftwareX 7, 107 (2018),
25  * <http://dx.doi.org/10.1016/j.softx.2018.03.005>
26  *
27  * For further information about Ergo, see <http://www.ergoscf.org>.
28  */
29 
30  /* This file belongs to the template_lapack part of the Ergo source
31  * code. The source files in the template_lapack directory are modified
32  * versions of files originally distributed as CLAPACK, see the
33  * Copyright/license notice in the file template_lapack/COPYING.
34  */
35 
36 
37 #ifndef TEMPLATE_BLAS_BASICMATH_HEADER
38 #define TEMPLATE_BLAS_BASICMATH_HEADER
39 
41 
42 template<class Treal>
43 Treal template_blas_fabs(Treal x);
44 
45 template<class Treal>
46 Treal template_blas_sqrt(Treal x);
47 
48 template<class Treal>
49 Treal template_blas_exp(Treal x);
50 
51 template<class Treal>
52 Treal template_blas_log(Treal x);
53 
54 template<class Treal>
55 Treal template_blas_log10(Treal x);
56 
57 template<class Treal>
58 Treal template_blas_erf(Treal x);
59 
60 template<class Treal>
61 Treal template_blas_erfc(Treal x);
62 
63 template<class Treal>
64 Treal template_blas_sin(Treal x);
65 
66 template<class Treal>
67 Treal template_blas_cos(Treal x);
68 
69 template<class Treal>
70 Treal template_blas_pow(Treal x, Treal y);
71 
72 
73 /* template_blas_compute_pi_BBP
74  This routine computes the number pi up to the precision of Treal
75  using the BBP formula. */
76 template<class Treal>
77 Treal template_blas_compute_pi_BBP(Treal dummy)
78 {
79  Treal epsilon = template_blas_get_machine_epsilon<Treal>();
80  Treal one_over_16 = (Treal)1 / (Treal)16;
81  Treal one_over_16_to_pow_k = 1;
82  Treal sum = 0;
83  int k = 0;
84  do
85  {
86  Treal factor =
87  (Treal)4 / (Treal)(8*k + 1) -
88  (Treal)2 / (Treal)(8*k + 4) -
89  (Treal)1 / (Treal)(8*k + 5) -
90  (Treal)1 / (Treal)(8*k + 6);
91  sum += one_over_16_to_pow_k * factor;
92  k++;
93  one_over_16_to_pow_k *= one_over_16;
94  }
95  while(one_over_16_to_pow_k > epsilon);
96  return sum;
97 }
98 
99 
100 #endif
Treal template_blas_cos(Treal x)
Treal template_blas_pow(Treal x, Treal y)
Treal template_blas_erfc(Treal x)
Treal template_blas_fabs(Treal x)
Treal template_blas_exp(Treal x)
Treal template_blas_log(Treal x)
Treal template_blas_sin(Treal x)
Treal template_blas_log10(Treal x)
Treal template_blas_erf(Treal x)
Treal template_blas_compute_pi_BBP(Treal dummy)
Definition: template_blas_basicmath.h:77
Treal template_blas_sqrt(Treal x)