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


Category:algorithms Component type:function
Prototype
template <class Vector>
linalg_traits<Vector>::magnitude_type two_norm(const Vector& x) ;
Description
The square root of the sum of the squares of the elements of the container.
Definition
mtl.h
Requirements on types
  • Vector must have an associated magnitude_type that is the type of the absolute value of Vector::value_type.
  • There must be abs() defined for Vector::value_type.
  • The addition must be defined for magnitude_type.
  • sqrt() must be defined for magnitude_type.
Preconditions
Complexity
O(n)
Example
In vec_two_norm.cc:
  dense1D<double> x(10, 2.0);
  double s = two_norm(x);
  cout << s << endl;

Notes
See also

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