Sleipnir C++ API
Loading...
Searching...
No Matches
Gradient.hpp
Go to the documentation of this file.
1// Copyright (c) Sleipnir contributors
2
3#pragma once
4
5#include <utility>
6
7#include <Eigen/SparseCore>
8
14
15namespace sleipnir {
16
25 public:
32 Gradient(Variable variable, Variable wrt) noexcept
33 : Gradient{std::move(variable), VariableMatrix{wrt}} {}
34
42 Gradient(Variable variable, const VariableMatrix& wrt) noexcept
43 : m_jacobian{variable, wrt} {}
44
51 VariableMatrix Get() const { return m_jacobian.Get().T(); }
52
56 const Eigen::SparseVector<double>& Value() {
57 m_g = m_jacobian.Value();
58
59 return m_g;
60 }
61
65 Profiler& GetProfiler() { return m_jacobian.GetProfiler(); }
66
67 private:
68 Eigen::SparseVector<double> m_g;
69
70 Jacobian m_jacobian;
71};
72
73} // namespace sleipnir
#define SLEIPNIR_DLLEXPORT
Definition SymbolExports.hpp:34
Definition Gradient.hpp:24
const Eigen::SparseVector< double > & Value()
Definition Gradient.hpp:56
Gradient(Variable variable, const VariableMatrix &wrt) noexcept
Definition Gradient.hpp:42
Gradient(Variable variable, Variable wrt) noexcept
Definition Gradient.hpp:32
Profiler & GetProfiler()
Definition Gradient.hpp:65
VariableMatrix Get() const
Definition Gradient.hpp:51
Definition Jacobian.hpp:25
Definition Profiler.hpp:13
Definition VariableMatrix.hpp:28
VariableMatrix T() const
Definition VariableMatrix.hpp:758
Definition Variable.hpp:33
Definition Expression.hpp:18