/autograd.hpp Secret
Created
January 3, 2021 23:03
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#ifndef AUTOGRAD_HPP_ | |
#define AUTOGRAD_HPP_ | |
#include "dual.hpp" | |
#include <functional> | |
#include <vector> | |
// simple 1D derivative | |
std::function<double(double)> derivative(std::function<Dual(Dual)> f); | |
// some shorthands | |
typedef std::vector<double> RealVec; | |
typedef std::vector<Dual> DualVec; | |
// gradient | |
std::function<RealVec(const RealVec&)> gradient(std::function<Dual(const DualVec&)> F); | |
// directional derivative | |
std::function<double(const RealVec&, const RealVec&)> grad_vec_prod(std::function<Dual(const DualVec&)> F); | |
#endif |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment