File size: 737 Bytes
8652957
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#ifndef LM_INTERPOLATE_BACKOFF_MATRIX_H
#define LM_INTERPOLATE_BACKOFF_MATRIX_H

#include <cstddef>
#include <vector>

namespace lm { namespace interpolate {

class BackoffMatrix {
  public:
    BackoffMatrix(std::size_t num_models, std::size_t max_order)
      : max_order_(max_order), backing_(num_models * max_order) {}

    float &Backoff(std::size_t model, std::size_t order_minus_1) {
      return backing_[model * max_order_ + order_minus_1];
    }

    float Backoff(std::size_t model, std::size_t order_minus_1) const {
      return backing_[model * max_order_ + order_minus_1];
    }

  private:
    const std::size_t max_order_;
    std::vector<float> backing_;
};

}} // namespaces

#endif // LM_INTERPOLATE_BACKOFF_MATRIX_H