sum [MTL Home] Programmers Guide
  Contents | Index |  Search 


Category:algorithms Component type:function
Prototype
template <class Vector>
linalg_traits<Vector>::value_type sum(const Vector& x) ;
Description
The sum of all of the elements in the container.
Definition
mtl.h
Requirements on types
  • The addition operator must be defined for Vector::value_type.
Preconditions
Complexity
linear
Example
In vec_sum.cc:
  mtl::dense1D< double > x(10, 2.0);
  double s = mtl::sum(x);
  cout << s << endl;

Notes
See also

[MTL Home] Copyright © 1998,1999 University of Notre Dame. All Rights Reserved.