diff --git a/Sheet5/mylib.h b/Sheet5/mylib.h deleted file mode 100644 index 0a5ddd9..0000000 --- a/Sheet5/mylib.h +++ /dev/null @@ -1,68 +0,0 @@ -#pragma once -#include -#include // setw() -#include -#include -#include - -/** Inner product - @param[in] x vector - @param[in] y vector - @return resulting Euclidian inner product -*/ -double scalar(std::vector const &x, std::vector const &y); -double scalar_trans(std::vector const &x, std::vector const &y); - -/** Second inner product: use #pragma omp parallel (no "for" in pragma) - The work is split manually inside the parallel region (stride or chunk). -*/ -double scalar_manual(std::vector const &x, std::vector const &y); - -/** l2-norm - @param[in] x vector - @return resulting Euclidian norm -*/ -double norm(std::vector const &x); - -/** Vector @p b adds its elements to vector @p a . - @param[in] a vector - @param[in] b vector - @return a+=b componentwise -*/ -template -std::vector &operator+=(std::vector &a, std::vector const &b) -{ - assert(a.size()==b.size()); - for (size_t k = 0; k < a.size(); ++k) { - a[k] += b[k]; - } - return a; -} - -// Declare the reduction operation in OpenMP for an STL-vector (existing) -#pragma omp declare reduction(VecAdd : std::vector : omp_out += omp_in) \ - initializer (omp_priv=omp_orig) - -/** Test for vector reduction. - * existing: converts thread-private vectors into a componentwise sum - * @param[in] n size of global/private vector - * @return resulting global vector. -*/ -std::vector reduction_vec(int n); - -/** New: append per-thread vectors into a single big vector. - * The result will have size n * numThreads, where each thread contributes a contiguous block. - */ -std::vector reduction_vec_append(int n); - -/** Output of a vector. - @param[in,out] s output stream - @param[in] x vector - @return modified output stream -*/ -template -std::ostream &operator<<(std::ostream &s, std::vector const &x) -{ - for (auto const &v : x) s << std::setw(4) << v << " "; - return s; -}