/usr/include/libint2/util/vector.h is in libint2-dev 2.3.0~beta3-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 | /*
* This file is a part of Libint.
* Copyright (C) 2004-2014 Edward F. Valeev
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Library General Public License, version 2,
* as published by the Free Software Foundation.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU Library General Public License
* along with this program. If not, see http://www.gnu.org/licenses/.
*
*/
#ifndef _libint2_src_lib_libint_vector_h_
#define _libint2_src_lib_libint_vector_h_
#include <unistd.h>
#if defined(__cplusplus)
#include <algorithm>
#include <libint2/util/type_traits.h>
namespace libint2 {
/**
Contains data types that support SIMD-style computation on vectors of numbers.
*/
namespace simd {
// add __declspec(align(N*sizeof(T))) ?
/**
* Vector<N,T> is used by vectorized Libint library as fixed-length vectors amenable for SIMD-style parallelism
* Vectorization via this class should be the last-resort measure if no specialized implementation is available
*/
template <size_t N, typename T>
struct Vector {
T d[N];
/**
* creates a vector of default-initialized values.
*/
Vector() {}
/** Initializes all elements to the same value
* @param a the value to which all elements will be set
*/
Vector(T a) {
std::fill_n(&(d[0]), N, a);
}
/**
* creates a vector of values initialized by an ordinary static-sized array
*/
Vector(T (&a)[N]) {
std::copy(&a[0], &a[0]+N, &d[0]);
}
Vector& operator=(T a) {
for(size_t i=0; i<N; ++i)
d[i] = a;
return *this;
}
Vector& operator+=(Vector a) {
for(size_t i=0; i<N; ++i)
d[i] += a.d[i];
return *this;
}
Vector& operator-=(Vector a) {
for(size_t i=0; i<N; ++i)
d[i] -= a.d[i];
return *this;
}
operator double() const {
return d[0];
}
};
//@{ arithmetic operators
template <size_t N, typename T>
Vector<N,T> operator*(T a, Vector<N,T> b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = a * b.d[i];
return c;
}
template <size_t N, typename T>
Vector<N,T> operator*(Vector<N,T> a, T b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = b * a.d[i];
return c;
}
template <size_t N, typename T>
Vector<N,T> operator*(int a, Vector<N,T> b) {
if (a == 1)
return b;
else {
Vector<N, T> c;
for (size_t i = 0; i < N; ++i)
c.d[i] = a * b.d[i];
return c;
}
}
template <size_t N, typename T>
Vector<N,T> operator*(Vector<N,T> a, int b) {
if (b == 1)
return a;
else {
Vector<N, T> c;
for (size_t i = 0; i < N; ++i)
c.d[i] = b * a.d[i];
return c;
}
}
template <size_t N, typename T>
Vector<N,T> operator*(Vector<N,T> a, Vector<N,T> b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = a.d[i] * b.d[i];
return c;
}
template <size_t N, typename T>
Vector<N,T> operator+(Vector<N,T> a, Vector<N,T> b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = a.d[i] + b.d[i];
return c;
}
template <size_t N, typename T>
Vector<N,T> operator-(Vector<N,T> a, Vector<N,T> b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = a.d[i] - b.d[i];
return c;
}
template <size_t N, typename T>
Vector<N,T> operator/(Vector<N,T> a, Vector<N,T> b) {
Vector<N,T> c;
for(size_t i=0; i<N; ++i)
c.d[i] = a.d[i] / b.d[i];
return c;
}
//@}
};}; // namespace libint2::simd
namespace libint2 {
template <size_t N, typename T>
struct is_vector<simd::Vector<N,T> > {
static const bool value = true;
};
template <size_t N, typename T>
struct vector_traits<simd::Vector<N,T> > {
typedef T value_type;
static const size_t extent = N;
};
} // namespace libint2
#include "vector_x86.h"
#include "vector_ppc.h"
#endif // C++ only
#endif
|