Skip to content

Commit

Permalink
Cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
mpmendenhall committed Jul 29, 2018
1 parent 78cddb1 commit af29246
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 12 deletions.
9 changes: 0 additions & 9 deletions Math/PolyEval.hh
Original file line number Diff line number Diff line change
Expand Up @@ -73,15 +73,6 @@ public:
template<class P>
void addPolynomial(const P& p, vector<T>& v) { for(auto& m: p) addMonomial(m,v); }

/// Comparison simple algorithm
template<class P, class Cvec>
void addSimple(const P& p, vector<T>& v, const Cvec& c) const {
if(!v.size()) v.resize(c.size());
assert(v.size() <= c.size());
size_t i = 0;
for(auto& y: v) y += p(c[i++]);
}

protected:
vector<vector<T>> Xs; ///< loaded coordinate vectors
vector<PowerSeriesEval<vector<T>>> Ps; /// Powers by variable
Expand Down
4 changes: 2 additions & 2 deletions Math/PowerSeriesEval.hh
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@
template<typename Vec>
class PowerSeriesEval {
public:

/// return value, deduced from vector type
typedef typename std::remove_reference<decltype(std::declval<Vec&>()[0])>::type T;

/// set x^1 values
Expand All @@ -41,7 +41,7 @@ public:
}
}

/// multiply by x^n
/// multiply vector by x^n
void mul(Vec& v0, size_t n) {
if(!n) return;
auto& x = pow(n);
Expand Down
11 changes: 10 additions & 1 deletion Test/testPolynomial.cc
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,15 @@ using std::chrono::steady_clock;
typedef Monomial_t<3> Mxyz;
typedef Polynomial_t<3> Pxyz;

/// Comparison simple algorithm
template<class P, class T, class Cvec>
void addSimple(const P& p, vector<T>& v, const Cvec& c) {
if(!v.size()) v.resize(c.size());
assert(v.size() <= c.size());
size_t i = 0;
for(auto& y: v) y += p(c[i++]);
}

int main(int, char**) {

std::vector<double> x(3);
Expand Down Expand Up @@ -47,7 +56,7 @@ int main(int, char**) {

auto t1 = steady_clock::now();

for(int i=0; i<ntrials; i++) PE.addSimple(p, vp2, vc);
for(int i=0; i<ntrials; i++) addSimple(p, vp2, vc);

auto t2 = steady_clock::now();

Expand Down

0 comments on commit af29246

Please sign in to comment.