ex5
This commit is contained in:
parent
0386d99307
commit
95b3017475
28 changed files with 5800 additions and 0 deletions
33
ex5/code/task_3.h
Normal file
33
ex5/code/task_3.h
Normal file
|
|
@ -0,0 +1,33 @@
|
|||
#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)
|
||||
Loading…
Add table
Add a link
Reference in a new issue