-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
tlming16
committed
Mar 12, 2020
1 parent
b22d024
commit 7c69a73
Showing
2 changed files
with
48 additions
and
6 deletions.
There are no files selected for viewing
This file contains 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
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 | ||
|
This file contains 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
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 |