Skip to content

Commit

Permalink
adding helper functions
Browse files Browse the repository at this point in the history
  • Loading branch information
Alexander Voigt authored and Alexander Voigt committed Nov 3, 2016
1 parent 3b84ec1 commit 8034e85
Showing 1 changed file with 9 additions and 1 deletion.
10 changes: 9 additions & 1 deletion src/linalg.h
Expand Up @@ -125,10 +125,18 @@ class DoubleVector : public Indexable<double, DoubleVector> {
return m;
}

DoubleVector abs() const {
return DoubleVector(std::abs(x), start, end);
}

double absmax(int & p) const {
return abs().max(p);
}

double min(int & p) const;///< minimum element in vector
double sum() const { return x.sum(); }
/// Returns sum of absolute values of all elements
double sumElements() const { return abs(x).sum(); }
double sumElements() const { return std::abs(x).sum(); }
std::size_t size() const { return x.size(); }

void swap(int i, int j); ///< swaps ith and jth elements of a vector
Expand Down

0 comments on commit 8034e85

Please sign in to comment.