Skip to content

Commit

Permalink
add autodiff
Browse files Browse the repository at this point in the history
  • Loading branch information
tlming16 committed Mar 12, 2020
1 parent b22d024 commit 7c69a73
Show file tree
Hide file tree
Showing 2 changed files with 48 additions and 6 deletions.
14 changes: 8 additions & 6 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,8 +1,10 @@
# Project_Euler
* cpp
* julia
* go
* d
* python


# AUTODIFF

cpp
julia
go
d
python

40 changes: 40 additions & 0 deletions autodiff/var.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
/*
* 2020.03.12
* tlming16
*/

# ifndef VAR_H
#define VAR_H
# include <string>
namespace mml{
class var{
public:
var():value_(0),grad_(1){ }
var(double v,double g=1.0):value_(v),grad_(g){}
var(const var &) =default;
var(var &&) = default ;
var operator =(const var &) = default ;
var operator =(var &&) = default ;
var operator + (const var &);
var operator - (const var &);
var operator / (const var &);
var operator * (const var &);
static var sin(const var &) ;
static var cos(const var &);
static var tan(const var &);
static var exp(const var &);
static var abs(const var &);
static var log (const var &);
static var pow (const var &);
std::string str() const;
private:
double value_=0;
double grad_=1;

};

var make_var(double val){
return var(val,1.0);
}
} // end of namespace mml
#endif

0 comments on commit 7c69a73

Please sign in to comment.