| 374 | |
| 375 | template <typename T> |
| 376 | typename T::value_type::second_type length_squared ( |
| 377 | const T& a |
| 378 | ) |
| 379 | { |
| 380 | typedef typename T::value_type::second_type scalar_type; |
| 381 | |
| 382 | typename T::const_iterator i; |
| 383 | |
| 384 | scalar_type sum = 0; |
| 385 | |
| 386 | for (i = a.begin(); i != a.end(); ++i) |
| 387 | { |
| 388 | sum += i->second * i->second; |
| 389 | } |
| 390 | |
| 391 | return sum; |
| 392 | } |
| 393 | |
| 394 | // ------------------------------------------------------------------------------------ |
| 395 |