OR-Tools  8.2
cached_log.h
Go to the documentation of this file.
1// Copyright 2010-2018 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_UTIL_CACHED_LOG_H_
15#define OR_TOOLS_UTIL_CACHED_LOG_H_
16
17#include <math.h>
18
19#include <vector>
20
24#include "ortools/base/macros.h"
25
26namespace operations_research {
27// This class is used when manipulating search space estimations. It
28// provides fast access to log of a domain size.
29// Future Extensions:
30// - Sum of log on an array.
31// - Sum of log on an array with callback.
32
33class CachedLog {
34 public:
35 CachedLog();
36 ~CachedLog();
37
38 // This method can only be called once, and with a cache_size > 0.
39 void Init(int cache_size);
40
41 // Returns the log2 of 'input'.
42 double Log2(int64 input) const;
43
44 private:
45 std::vector<double> cache_;
46 DISALLOW_COPY_AND_ASSIGN(CachedLog);
47};
48} // namespace operations_research
49
50#endif // OR_TOOLS_UTIL_CACHED_LOG_H_
double Log2(int64 input) const
Definition: cached_log.cc:43
void Init(int cache_size)
Definition: cached_log.cc:34
int64_t int64
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
static int input(yyscan_t yyscanner)