1 template <
size_t Size,
typename T>
6 template <
size_t Size,
typename T>
8 std::memcpy(_data.data(), values,
sizeof(T) * Size);
11 template <
size_t Size,
typename T>
13 std::copy(std::begin(list), std::end(list), std::begin(_data));
16 template <
size_t Size,
typename T>
21 template <
size_t Size,
typename T>
26 template <
size_t Size,
typename T>
31 template <
size_t Size,
typename T>
36 template <
size_t Size,
typename T>
41 template <
size_t Size,
typename T>
43 return std::accumulate(std::begin(_data), std::end(_data), T(0));
47 template <
size_t Size,
typename T>
49 for (
size_t i = 0; i < Size; ++i) {
56 template <
size_t Size,
typename T>
58 for (
size_t i = 0; i < Size; ++i) {
65 template <
size_t Size,
typename T>
67 for (
size_t i = 0; i < Size; ++i) {
74 template <
size_t Size,
typename T>
76 for (
size_t i = 0; i < Size; ++i) {
84 template <
size_t Size,
typename T>
86 for (
size_t i = 0; i < Size; ++i) {
93 template <
size_t Size,
typename T>
95 for (
size_t i = 0; i < Size; ++i) {
102 template <
size_t Size,
typename T>
104 for (
size_t i = 0; i < Size; ++i) {
111 template <
size_t Size,
typename T>
113 for (
size_t i = 0; i < Size; ++i) {
121 template <
size_t Size,
typename T>
122 inline ValArray<Size, T>
operator+(
const ValArray<Size, T>& lhs,
const T& rhs) {
123 ValArray<Size, T> array{lhs};
125 for (
size_t i = 0; i < Size; ++i) {
132 template <
size_t Size,
typename T>
133 inline ValArray<Size, T>
operator-(
const ValArray<Size, T>& lhs,
const T& rhs) {
134 ValArray<Size, T> array{lhs};
136 for (
size_t i = 0; i < Size; ++i) {
143 template <
size_t Size,
typename T>
144 inline ValArray<Size, T>
operator*(
const ValArray<Size, T>& lhs,
const T& rhs) {
145 ValArray<Size, T> array{lhs};
147 for (
size_t i = 0; i < Size; ++i) {
154 template <
size_t Size,
typename T>
155 inline ValArray<Size, T>
operator/(
const ValArray<Size, T>& lhs,
const T& rhs) {
156 ValArray<Size, T> array{lhs};
158 for (
size_t i = 0; i < Size; ++i) {
165 template <
size_t Size,
typename T>
166 inline ValArray<Size, T>
operator+(
const T& lhs,
const ValArray<Size, T>& rhs) {
167 ValArray<Size, T> array{rhs};
169 for (
size_t i = 0; i < Size; ++i) {
170 array[i] = lhs + array[i];
176 template <
size_t Size,
typename T>
177 inline ValArray<Size, T>
operator-(
const T& lhs,
const ValArray<Size, T>& rhs) {
178 ValArray<Size, T> array{rhs};
180 for (
size_t i = 0; i < Size; ++i) {
181 array[i] = lhs - array[i];
187 template <
size_t Size,
typename T>
188 inline ValArray<Size, T>
operator*(
const T& lhs,
const ValArray<Size, T>& rhs) {
189 ValArray<Size, T> array{rhs};
191 for (
size_t i = 0; i < Size; ++i) {
192 array[i] = lhs * array[i];
198 template <
size_t Size,
typename T>
199 inline ValArray<Size, T>
operator/(
const T& lhs,
const ValArray<Size, T>& rhs) {
200 ValArray<Size, T> array{rhs};
202 for (
size_t i = 0; i < Size; ++i) {
203 array[i] = lhs / array[i];
210 template <
size_t Size,
typename T>
211 inline ValArray<Size, T>
operator+(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
212 ValArray<Size, T> array{lhs};
214 for (
size_t i = 0; i < Size; ++i) {
221 template <
size_t Size,
typename T>
222 inline ValArray<Size, T>
operator-(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
223 ValArray<Size, T> array{lhs};
225 for (
size_t i = 0; i < Size; ++i) {
232 template <
size_t Size,
typename T>
233 inline ValArray<Size, T>
operator*(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
234 ValArray<Size, T> array{lhs};
236 for (
size_t i = 0; i < Size; ++i) {
243 template <
size_t Size,
typename T>
244 inline ValArray<Size, T>
operator/(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
245 ValArray<Size, T> array{lhs};
247 for (
size_t i = 0; i < Size; ++i) {
254 template <
size_t Size,
typename T>
255 inline bool operator==(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
256 return std::equal(std::begin(lhs.data()), std::end(lhs.data()), std::begin(rhs.data()), std::end(rhs.data()));
259 template <
size_t Size,
typename T>
260 inline bool operator!=(
const ValArray<Size, T>& lhs,
const ValArray<Size, T>& rhs) {
261 return !std::equal(std::begin(lhs.data()), std::end(lhs.data()), std::begin(rhs.data()), std::end(rhs.data()));
ValArray< Size, T > operator*(const ValArray< Size, T > &lhs, const T &rhs)
bool operator==(const ValArray< Size, T > &lhs, const ValArray< Size, T > &rhs)
ValArray< Size, T > operator-(const ValArray< Size, T > &lhs, const T &rhs)
bool operator!=(const ValArray< Size, T > &lhs, const ValArray< Size, T > &rhs)
ValArray< Size, T > operator/(const ValArray< Size, T > &lhs, const T &rhs)
ValArray< Size, T > operator+(const ValArray< Size, T > &lhs, const T &rhs)