Apollo  6.0
Open source self driving car software
polynomial.h
Go to the documentation of this file.
1 /******************************************************************************
2  * Copyright 2018 The Apollo Authors. All Rights Reserved.
3  *
4  * Licensed under the Apache License, Version 2.0 (the "License");
5  * you may not use this file except in compliance with the License.
6  * You may obtain a copy of the License at
7  *
8  * http://www.apache.org/licenses/LICENSE-2.0
9  *
10  * Unless required by applicable law or agreed to in writing, software
11  * distributed under the License is distributed on an "AS IS" BASIS,
12  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13  * See the License for the specific language governing permissions and
14  * limitations under the License.
15  *****************************************************************************/
16 #pragma once
17 
18 #include <iostream>
19 #include <map>
20 #include <vector>
21 
22 namespace apollo {
23 namespace perception {
24 namespace base {
25 
26 class Polynomial {
27  public:
28  Polynomial();
29  ~Polynomial();
30  double& operator[](const uint32_t& order);
31  // sum(coeff_[i] * x^i)
32  double operator()(const double& x);
33 
34  const std::map<uint32_t, double>& getCoeff() const;
35 
36  private:
37  std::map<uint32_t, double> coeff_;
38  std::vector<uint32_t> index_gap_;
39  std::map<uint32_t, double> power_cache_;
40  bool initialized_ = false;
41 };
42 
43 std::ostream& operator<<(std::ostream& o, const Polynomial& p);
44 
45 } // namespace base
46 } // namespace perception
47 } // namespace apollo
Definition: polynomial.h:26
PlanningContext is the runtime context in planning. It is persistent across multiple frames...
Definition: atomic_hash_map.h:25
const std::map< uint32_t, double > & getCoeff() const
double & operator[](const uint32_t &order)
std::ostream & operator<<(std::ostream &o, const Polynomial &p)
double operator()(const double &x)