LIBINT  2.6.0
intrinsic_operations.h
1 /*
2  * Copyright (C) 2004-2019 Edward F. Valeev
3  *
4  * This file is part of Libint.
5  *
6  * Libint is free software: you can redistribute it and/or modify
7  * it under the terms of the GNU Lesser 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  * Libint 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 Lesser General Public License for more details.
15  *
16  * You should have received a copy of the GNU Lesser General Public License
17  * along with Libint. If not, see <http://www.gnu.org/licenses/>.
18  *
19  */
20 
21 #ifndef _libint2_include_libint2intrinsicoperations_h_
22 #define _libint2_include_libint2intrinsicoperations_h_
23 
24 #include <libint2/config.h>
25 
26 #ifdef __cplusplus
27 
28 namespace libint2 {
29 
31 
32 #if defined(LIBINT_GENERATE_FMA)
33 # if defined(LIBINT_HAS_CXX11)
34  template <typename X, typename Y, typename Z>
36  inline auto fma_plus(X x, Y y, Z z) -> decltype(x*y+z) {
37  return x*y + z;
38  }
39 
41  template <typename X, typename Y, typename Z>
42  inline auto fma_minus(X x, Y y, Z z) -> decltype(x*y-z) {
43  return x*y - z;
44  }
45 # else // LIBINT_HAS_CXX11
46 # error "support for FMA requires compiler capable of C++11 or later"
47 # endif // LIBINT_HAS_CXX11
48 #endif // LIBINT_GENERATE_FMA
49 
51 
52 };
53 
58 #define _libint2_static_api_bzero_short_(X,nelem) for(int i=0; i < (nelem); ++i) { (X)[i] = 0.0; }
59 
60 #define _libint2_static_api_copy_short_(X,Y,nelem) for(int i=0; i < (nelem); ++i) { (X)[i] = (Y)[i]; }
61 
62 #define _libint2_static_api_scale_short_(X,Y,nelem,a) for(int i=0; i < (nelem); ++i) { (X)[i] = (a) * (Y)[i]; }
63 
64 #define _libint2_static_api_scale_vec_short_(X,Y,nelem,a,vl) for(int i=0, iv=0; i < (nelem)/(vl); ++i) { for(int v=0; v < (vl); ++v, ++iv) { (X)[iv] = (a)[v] * (Y)[iv]; } }
65 
66 #if defined(LIBINT_GENERATE_FMA)
67 # define _libint2_static_api_inc_short_(X,Y,nelem,a) for(int i=0; i < (nelem); ++i) { (X)[i] = libint2::fma_plus((a),(Y)[i],(X)[i]); }
68 #else
69 # define _libint2_static_api_inc_short_(X,Y,nelem,a) for(int i=0; i < (nelem); ++i) { (X)[i] += (a) * (Y)[i]; }
70 #endif
71 
72 #define _libint2_static_api_inc1_short_(X,Y,nelem) for(int i=0; i < (nelem); ++i) { (X)[i] += (Y)[i]; }
73 
74 #endif
75 
76 #endif
Defaults definitions for various parameters assumed by Libint.
Definition: algebra.cc:24
auto fma_plus(X x, Y y, Z z) -> decltype(x *y+z)
Definition: intrinsic_operations.h:36
auto fma_minus(X x, Y y, Z z) -> decltype(x *y-z)
Definition: intrinsic_operations.h:42