33 lines
856 B
C++
33 lines
856 B
C++
#pragma once
|
|
#include <cassert>
|
|
#include <vector>
|
|
using namespace std;
|
|
|
|
|
|
// Counts number of possible decompositions with 2 primes that sum up to k.
|
|
int single_goldbach_par(int k);
|
|
|
|
// Counts number of possible decompositions with 2 primes that sum up to k for all even numbers k \in {4,...,n}.
|
|
vector<int> count_goldbach_par(int n);
|
|
|
|
// Prints all decompositions of k.
|
|
void print_decomps(int k);
|
|
|
|
|
|
/** Vector @p b adds its elements to vector @p a .
|
|
@param[in] a vector
|
|
@param[in] b vector
|
|
@return a+=b componentwise
|
|
*/
|
|
template<class T>
|
|
std::vector<T> &operator+=(std::vector<T> &a, std::vector<T> const &b)
|
|
{
|
|
assert(a.size()==b.size());
|
|
for (size_t k = 0; k < a.size(); ++k) {
|
|
a[k] += b[k];
|
|
}
|
|
return a;
|
|
}
|
|
|
|
#pragma omp declare reduction(VecAdd : std::vector<int> : omp_out += omp_in) \
|
|
initializer (omp_priv=omp_orig)
|