[Rd] : Operator overloading for custom classes

From: Chidambaram Annamalai <quantumelixir_at_gmail.com>
Date: Tue, 23 Mar 2010 14:07:39 +0530


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!

        [[alternative HTML version deleted]]

R-devel_at_r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel Received on Tue 23 Mar 2010 - 08:39:52 GMT

Archive maintained by Robert King, hosted by the discipline of statistics at the University of Newcastle, Australia.
Archive generated by hypermail 2.2.0, at Sat 27 Mar 2010 - 07:31:13 GMT.

Mailing list information is available at https://stat.ethz.ch/mailman/listinfo/r-devel. Please read the posting guide before posting to the list.

list of date sections of archive