| 50 | // -------------------------------------------------------------------------- |
| 51 | |
| 52 | void BowVector::normalize(LNorm norm_type) { |
| 53 | double norm = 0.0; |
| 54 | BowVector::iterator it; |
| 55 | |
| 56 | if (norm_type == DBoW2::L1) { |
| 57 | for (it = begin(); it != end(); ++it) norm += fabs(it->second); |
| 58 | } else { |
| 59 | for (it = begin(); it != end(); ++it) norm += it->second * it->second; |
| 60 | norm = sqrt(norm); |
| 61 | } |
| 62 | |
| 63 | if (norm > 0.0) { |
| 64 | for (it = begin(); it != end(); ++it) it->second /= norm; |
| 65 | } |
| 66 | } |
| 67 | |
| 68 | // -------------------------------------------------------------------------- |
| 69 |
no outgoing calls