diff options
-rw-r--r-- | order.cpp | 22 |
1 files changed, 15 insertions, 7 deletions
@@ -30,18 +30,21 @@ int main(int argc, char* argv[]) { std::transform(omp_out.begin(), omp_out.end(), omp_in.begin(), omp_out.begin(), std::plus<long int>())) \ initializer(omp_priv = decltype(omp_orig)(omp_orig.size())) - std::vector<long int> data_x(G.vertices.size() / 2); - std::vector<long int> data_y(G.vertices.size() / 2); + std::vector<long int> data_x(G.vertices.size()); + std::vector<long int> data_y(G.vertices.size()); std::string filename = "order_" + std::to_string(n) + ".dat"; std::ifstream input(filename); - for (unsigned i = 0; i < G.vertices.size() / 2; i++) { - input >> data_x[i]; - input >> data_y[i]; + if (input.is_open()) { + for (unsigned i = 0; i < G.vertices.size(); i++) { + input >> data_x[i]; + input >> data_y[i]; + } + + input.close(); } - input.close(); #pragma omp parallel for reduction(vec_int_plus : data_x) reduction(vec_int_plus : data_y) for (unsigned i = 0; i < m; i++) { @@ -61,12 +64,17 @@ int main(int argc, char* argv[]) { data_y[i] += G.vertices[i].coordinate[1]; data_x[i] -= G.vertices[j].coordinate[0]; data_y[i] -= G.vertices[j].coordinate[1]; + + data_x[j] += G.vertices[i].coordinate[0]; + data_y[j] += G.vertices[i].coordinate[1]; + data_x[j] -= G.vertices[j].coordinate[0]; + data_y[j] -= G.vertices[j].coordinate[1]; } } std::ofstream output(filename); - for (unsigned i = 0; i < G.vertices.size() / 2; i++) { + for (unsigned i = 0; i < G.vertices.size(); i++) { output << data_x[i] << " " << data_y[i] << std::endl; } |