ergo
template_blas_basicmath.h
Go to the documentation of this file.
1 /* Ergo, version 3.8, a program for linear scaling electronic structure
2  * calculations.
3  * Copyright (C) 2019 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
template_blas_pow
Treal template_blas_pow(Treal x, Treal y)
template_blas_sqrt
Treal template_blas_sqrt(Treal x)
template_blas_sqrt< float >
float template_blas_sqrt< float >(float x)
Definition: template_blas_basicmath.cc:81
template_blas_exp< float >
float template_blas_exp< float >(float x)
Definition: template_blas_basicmath.cc:107
template_blas_num_limits.h
template_blas_sin< double >
double template_blas_sin< double >(double x)
Definition: template_blas_basicmath.cc:240
template_blas_log10< long double >
long double template_blas_log10< long double >(long double x)
Definition: template_blas_basicmath.cc:167
template_blas_cos
Treal template_blas_cos(Treal x)
template_blas_log< double >
double template_blas_log< double >(double x)
Definition: template_blas_basicmath.cc:136
template_blas_exp
Treal template_blas_exp(Treal x)
template_blas_cos< long double >
long double template_blas_cos< long double >(long double x)
Definition: template_blas_basicmath.cc:271
template_blas_basicmath.h
template_blas_erfc
Treal template_blas_erfc(Treal x)
template_blas_fabs
Treal template_blas_fabs(Treal x)
template_blas_sqrt< long double >
long double template_blas_sqrt< long double >(long double x)
Definition: template_blas_basicmath.cc:89
template_blas_fabs< float >
float template_blas_fabs< float >(float x)
Definition: template_blas_basicmath.cc:55
template_blas_exp< double >
double template_blas_exp< double >(double x)
Definition: template_blas_basicmath.cc:110
template_blas_erf< float >
float template_blas_erf< float >(float x)
Definition: template_blas_basicmath.cc:185
template_blas_log10< double >
double template_blas_log10< double >(double x)
Definition: template_blas_basicmath.cc:162
template_blas_fabs< double >
double template_blas_fabs< double >(double x)
Definition: template_blas_basicmath.cc:58
template_blas_erfc< float >
float template_blas_erfc< float >(float x)
Definition: template_blas_basicmath.cc:211
template_blas_log10
Treal template_blas_log10(Treal x)
template_blas_log< float >
float template_blas_log< float >(float x)
Definition: template_blas_basicmath.cc:133
template_blas_erf
Treal template_blas_erf(Treal x)
template_blas_erfc< double >
double template_blas_erfc< double >(double x)
Definition: template_blas_basicmath.cc:214
template_blas_pow< double >
double template_blas_pow< double >(double x, double y)
Definition: template_blas_basicmath.cc:292
template_blas_erfc< long double >
long double template_blas_erfc< long double >(long double x)
Definition: template_blas_basicmath.cc:219
template_blas_sin
Treal template_blas_sin(Treal x)
template_blas_cos< float >
float template_blas_cos< float >(float x)
Definition: template_blas_basicmath.cc:263
template_blas_sin< float >
float template_blas_sin< float >(float x)
Definition: template_blas_basicmath.cc:237
template_blas_log
Treal template_blas_log(Treal x)
template_blas_erf< double >
double template_blas_erf< double >(double x)
Definition: template_blas_basicmath.cc:188
template_blas_pow< float >
float template_blas_pow< float >(float x, float y)
Definition: template_blas_basicmath.cc:289
template_blas_erf< long double >
long double template_blas_erf< long double >(long double x)
Definition: template_blas_basicmath.cc:193
template_blas_compute_pi_BBP
Treal template_blas_compute_pi_BBP(Treal dummy)
Definition: template_blas_basicmath.h:77
template_blas_cos< double >
double template_blas_cos< double >(double x)
Definition: template_blas_basicmath.cc:266
template_blas_pow< long double >
long double template_blas_pow< long double >(long double x, long double y)
Definition: template_blas_basicmath.cc:297
config.h
template_blas_sin< long double >
long double template_blas_sin< long double >(long double x)
Definition: template_blas_basicmath.cc:245
template_blas_fabs< long double >
long double template_blas_fabs< long double >(long double x)
Definition: template_blas_basicmath.cc:63
template_blas_log10< float >
float template_blas_log10< float >(float x)
Definition: template_blas_basicmath.cc:159
template_blas_log< long double >
long double template_blas_log< long double >(long double x)
Definition: template_blas_basicmath.cc:141
template_blas_sqrt< double >
double template_blas_sqrt< double >(double x)
Definition: template_blas_basicmath.cc:84
template_blas_exp< long double >
long double template_blas_exp< long double >(long double x)
Definition: template_blas_basicmath.cc:115