Google OR-Tools
v9.15
a fast and portable software suite for combinatorial optimization
Loading...
Searching...
No Matches
cached_log.h
Go to the documentation of this file.
1
// Copyright 2010-2025 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 ORTOOLS_UTIL_CACHED_LOG_H_
15
#define ORTOOLS_UTIL_CACHED_LOG_H_
16
17
#include <cstdint>
18
#include <vector>
19
20
namespace
operations_research
{
21
// This class is used when manipulating search space estimations. It
22
// provides fast access to log of a domain size.
23
// Future Extensions:
24
// - Sum of log on an array.
25
// - Sum of log on an array with callback.
26
27
class
CachedLog
{
28
public
:
29
CachedLog
();
30
31
// This type is neither copyable nor movable.
32
CachedLog
(
const
CachedLog
&) =
delete
;
33
CachedLog
&
operator=
(
const
CachedLog
&) =
delete
;
34
35
~CachedLog
();
36
37
// This method can only be called once, and with a cache_size > 0.
38
void
Init
(
int
cache_size);
39
40
// Returns the log2 of 'input'.
41
double
Log2
(int64_t
input
)
const
;
42
43
private
:
44
std::vector<double> cache_;
45
};
46
}
// namespace operations_research
47
48
#endif
// ORTOOLS_UTIL_CACHED_LOG_H_
operations_research::CachedLog::Log2
double Log2(int64_t input) const
Definition
cached_log.cc:43
operations_research::CachedLog::Init
void Init(int cache_size)
Definition
cached_log.cc:34
operations_research::CachedLog::CachedLog
CachedLog()
Definition
cached_log.cc:20
operations_research::CachedLog::~CachedLog
~CachedLog()
Definition
cached_log.cc:22
operations_research::CachedLog::CachedLog
CachedLog(const CachedLog &)=delete
operations_research::CachedLog::operator=
CachedLog & operator=(const CachedLog &)=delete
operations_research
OR-Tools root namespace.
Definition
binary_indexed_tree.h:21
input
static int input(yyscan_t yyscanner)
ortools
util
cached_log.h
Generated by
1.15.0