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


Category:algorithms Component type:function
Prototype
template<class Vec>
Vec::size_type min_abs_index(const Vec& x) ;
Description
The location (index) of the element with the minimum absolute value. is the type of the absolute value of its value_type.
Definition
mtl.h
Requirements on types
  • The vector or matrix must have an associated magnitude_type that
  • There must be abs() defined for Vector::value_type.
  • The magnitude type must be LessThanComparible.
Preconditions
Complexity
O(n)
Example
In max_index.cc:
typedef complex<float> c;
typedef external_vec<c> Vec;
  const int N = 5;
  c dx[] = { c(5,-4), c(-3,-2),
             c(5,-4), c(6,0), c(0,8) };
  Vec x(dx, N);
  
  int imax = max_index(x);

Notes
See also

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