blazing_spline_impl.hpp
1 /*
2  * This file is part of CasADi.
3  *
4  * CasADi -- A symbolic framework for dynamic optimization.
5  * Copyright (C) 2010-2023 Joel Andersson, Joris Gillis, Moritz Diehl,
6  * KU Leuven. All rights reserved.
7  * Copyright (C) 2011-2014 Greg Horn
8  *
9  * CasADi is free software; you can redistribute it and/or
10  * modify it under the terms of the GNU Lesser General Public
11  * License as published by the Free Software Foundation; either
12  * version 3 of the License, or (at your option) any later version.
13  *
14  * CasADi is distributed in the hope that it will be useful,
15  * but WITHOUT ANY WARRANTY; without even the implied warranty of
16  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
17  * Lesser General Public License for more details.
18  *
19  * You should have received a copy of the GNU Lesser General Public
20  * License along with CasADi; if not, write to the Free Software
21  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
22  *
23  */
24 
25 
26 #ifndef CASADI_BLAZING_SPLINE_IMPL_HPP
27 #define CASADI_BLAZING_SPLINE_IMPL_HPP
28 
29 #include "blazing_spline.hpp"
30 #include "function_internal.hpp"
31 
33 
34 namespace casadi {
35  class CASADI_EXPORT BlazingSplineFunction : public FunctionInternal {
36  public:
41  const std::string& name,
42  const std::vector< std::vector<double> >& knots,
43  casadi_int diff_order);
44 
48  std::string class_name() const override { return "BlazingSplineFunction";}
49 
53  ~BlazingSplineFunction() override;
54 
58  void merge(const std::vector<MX>& arg,
59  std::vector<MX>& subs_from, std::vector<MX>& subs_to) const override;
60 
62 
65  static const Options options_;
66  const Options& get_options() const override { return options_;}
68 
72  void init(const Dict& opts) override;
73 
74  void init_derived_members();
75 
79  bool has_codegen() const override { return true;}
80 
84  void codegen_body(CodeGenerator& g) const override;
85 
87 
90  bool has_jacobian() const override;
91  Function get_jacobian(const std::string& name,
92  const std::vector<std::string>& inames,
93  const std::vector<std::string>& onames,
94  const Dict& opts) const override;
96 
97  casadi_int diff_order_;
98  std::vector< std::vector<double> > knots_;
99 
100  // Derived fiels
101  std::vector<casadi_int> knots_offset_;
102  std::vector<double> knots_stacked_;
103 
104  // Coefficient tensor size
105  casadi_int nc_, ndc_, nddc_;
106 
108 
111  size_t get_n_in() override;
112  size_t get_n_out() override;
114 
118  bool get_diff_in(casadi_int i) override;
119 
121 
124  Sparsity get_sparsity_in(casadi_int i) override;
125  Sparsity get_sparsity_out(casadi_int i) override;
127 
129 
132  std::string get_name_in(casadi_int i) override;
133  std::string get_name_out(casadi_int i) override;
135 
139  void serialize_body(SerializingStream &s) const override;
140 
144  static ProtoFunction* deserialize(DeserializingStream& s);
145 
149  std::string serialize_base_function() const override { return "BlazingSplineFunction"; }
150 
151  protected:
156  };
157 
158 
159 } // namespace casadi
161 
162 #endif // CASADI_BLAZING_SPLINE_IMPL_HPP
std::vector< casadi_int > knots_offset_
std::vector< double > knots_stacked_
std::vector< std::vector< double > > knots_
std::string class_name() const override
Get type name.
static const Options options_
Options.
bool has_codegen() const override
Is codegen supported?
std::string serialize_base_function() const override
String used to identify the immediate FunctionInternal subclass.
const Options & get_options() const override
Options.
Helper class for C code generation.
Helper class for Serialization.
Internal class for Function.
Function object.
Definition: function.hpp:60
Base class for FunctionInternal and LinsolInternal.
Helper class for Serialization.
General sparsity class.
Definition: sparsity.hpp:106
The casadi namespace.
Definition: archiver.cpp:28
GenericType::Dict Dict
C++ equivalent of Python's dict or MATLAB's struct.
Options metadata for a class.
Definition: options.hpp:40