diff --git a/lib/node.cpp b/lib/node.cpp index 5f75e6ec8b51dfe4209e45635d7cb47f57fddd58..ce11458b4ffe0f84738fab7d28445e3e7eaae0e3 100644 --- a/lib/node.cpp +++ b/lib/node.cpp @@ -48,7 +48,7 @@ void Node::update(List localParticles, unsigned nLocalParticles) { // for each local particle, determine which octant it is in // get the mass in this node while we're at it for (unsigned i=0; i<8; ++i) { - childParticles_[i] = List{}; + childParticles_[i] = {}; } for (unsigned i : localParticles) { childParticles_[getOctant(i)].push_back(i); @@ -169,7 +169,7 @@ Vector Node::multipole(Vector y, double ynorm) const { double qij = 0; // go through every local particle for (unsigned c=0; c<8; ++c) { - for (auto k : childParticles_[c]) { + for (unsigned k : childParticles_[c]) { // calculate using the formula from page 17 of the pdf for lecture 7 qij += 3*(centerOfMass_[i] - positions_[3*k+i])*(centerOfMass_[j] - positions_[3*k+j]); if (i!=j) continue; diff --git a/lib/node.hpp b/lib/node.hpp index 1b4e732882150e55ed7c1de9662b918da5776847..0102ac4609adfcde214a861006e54e03a49819cc 100644 --- a/lib/node.hpp +++ b/lib/node.hpp @@ -2,11 +2,12 @@ #define NODE_HPP #include <vector> +#include <list> #include <fstream> using Vector = std::vector<double>; using Matrix = std::vector<Vector>; -using List = std::vector<unsigned>; +using List = std::list<unsigned>; class Node { public: diff --git a/lib/tree.cpp b/lib/tree.cpp index c9b84e0e8a592d8c4409082e88a7ae4458da6de1..5b6ef2656cef96cf8a3e8478ecf4719b8766d969 100644 --- a/lib/tree.cpp +++ b/lib/tree.cpp @@ -14,8 +14,8 @@ Tree::Tree(double mass, double* positions, double* forces, double softening, uns center_ = Vector(3); for (unsigned i=0; i < 3; ++i) center_[i] = center[i]; - allParticles_ = List(nParticles_); - for (unsigned i=0; i < nParticles_; ++i) allParticles_[i] = i; + allParticles_ = {}; + for (unsigned i=0; i < nParticles_; ++i) allParticles_.push_back(i); root_ = new Node(mass_, positions_, nParticles_, softening_, 0, size_, center_, allParticles_, nParticles_); }