Hi, I need some help to get some of the object orientation, specifically the methods that overload the basic arithmetic operations, from sample C++ code to R. I don't have experience with such advanced language features inside of R. So I was wondering if some of you could help me out in this regard.
I have written a simple demonstration of a forward mode automatic differentiator in C++ and it is currently hosted on github: http://github.com/quantumelixir/ad-demo/blob/master/simple.cpp. It uses simple operator overloading techniques to modify the meaning of the basic arithmetic operations (+, -, *, /) for the "derivative" type Dual number class that I have defined. Could you show me how this could be equivalently done in R? I want to know how to define custom classes and define the meaning of arithmetic for them. I had checked for operator overloading in R but could only find the equivalence of a + b and '+'(a, b) in the R language definition. Could you show how I could extend the simple object oriented-ness in the C++ code neatly to R? Thanks a bunch! Chillu PS: Sorry that I had mistakenly sent the email to the r-devel list earlier, instead of the intended r-help list. This is a copy of the same email. [[alternative HTML version deleted]] ______________________________________________ R-help@r-project.org mailing list https://stat.ethz.ch/mailman/listinfo/r-help PLEASE do read the posting guide http://www.R-project.org/posting-guide.html and provide commented, minimal, self-contained, reproducible code.