| 985 | // return the length of the provided vector |
| 986 | template< class T> |
| 987 | inline typename T::value_type length(const T &vec) |
| 988 | { |
| 989 | typename T::value_type r = 0; |
| 990 | |
| 991 | for (int i = 0; i < vec.size(); i++) |
| 992 | { |
| 993 | r += vec._array[i]*vec._array[i]; |
| 994 | } |
| 995 | |
| 996 | return typename T::value_type(sqrt(r)); |
| 997 | } |
| 998 | |
| 999 | // return the squared norm |
| 1000 | template< class T> |