Dear Tomas, Where do I find these files? Do they contain the code for the sum function? What do you mean exactly with your point on long doubles? Where can I find documentation on this? Cheers, Rampal On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com wrote:> See do_summary() in summary.c, rsum() for doubles. R uses long double > type as accumulator on systems where available. > > Best, > Tomas > > On 2/14/19 2:08 PM, Rampal Etienne wrote: > > Hello, > > > > I am trying to write FORTRAN code to do the same as some R code I > > have. I get (small) differences when using the sum function in R. I > > know there are numerical routines to improve precision, but I have not > > been able to figure out what algorithm R is using. Does anyone know > > this? Or where can I find the code for the sum function? > > > > Regards, > > > > Rampal Etienne > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > >[[alternative HTML version deleted]]
Dear Rampal, you can download R source code in form of a tarball or from subversion, please see https://cran.r-project.org/doc/manuals/R-admin.html#Obtaining-R https://cran.r-project.org/doc/manuals/R-admin.html#Using-Subversion-and-rsync There is also a web access to subversion, so specifically the sum is available in https://svn.r-project.org/R/trunk/src/main/summary.c The definition of LDOUBLE is here https://svn.r-project.org/R/trunk/src/include/Defn.h The index of R manuals is here https://cran.r-project.org/manuals.html The online documentation inside R gives for ?sum "??? Loss of accuracy can occur when summing values of different signs: ???? this can even occur for sufficiently long integer inputs if the ???? partial sums would cause integer overflow.? Where possible ???? extended-precision accumulators are used, typically well supported ???? with C99 and newer, but possibly platform-dependent. " Best, Tomas On 2/20/19 11:55 PM, Rampal Etienne wrote:> Dear Tomas, > > Where do I find these files? Do they contain the code for the sum > function? > > What do you mean exactly with your point on long doubles? Where can I > find documentation on this? > > Cheers, Rampal > > On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com > <mailto:tomas.kalibera at gmail.com> wrote: > > See do_summary() in summary.c, rsum() for doubles. R uses long double > type as accumulator on systems where available. > > Best, > Tomas > > On 2/14/19 2:08 PM, Rampal Etienne wrote: > > Hello, > > > > I am trying to write FORTRAN code to do the same as some R code I > > have. I get (small) differences when using the sum function in R. I > > know there are numerical routines to improve precision, but I > have not > > been able to figure out what algorithm R is using. Does anyone know > > this? Or where can I find the code for the sum function? > > > > Regards, > > > > Rampal Etienne > > > > ______________________________________________ > > R-devel at r-project.org <mailto:R-devel at r-project.org> mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > >[[alternative HTML version deleted]]
On 2/20/19 2:55 PM, Rampal Etienne wrote:> Dear Tomas, > > Where do I find these files? Do they contain the code for the sum function?Yes. https://svn.r-project.org/R/trunk/ David> > What do you mean exactly with your point on long doubles? Where can I find > documentation on this? > > Cheers, Rampal > > On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com wrote: > >> See do_summary() in summary.c, rsum() for doubles. R uses long double >> type as accumulator on systems where available. >> >> Best, >> Tomas >> >> On 2/14/19 2:08 PM, Rampal Etienne wrote: >>> Hello, >>> >>> I am trying to write FORTRAN code to do the same as some R code I >>> have. I get (small) differences when using the sum function in R. I >>> know there are numerical routines to improve precision, but I have not >>> been able to figure out what algorithm R is using. Does anyone know >>> this? Or where can I find the code for the sum function? >>> >>> Regards, >>> >>> Rampal Etienne >>> >>> ______________________________________________ >>> R-devel at r-project.org mailing list >>> https://stat.ethz.ch/mailman/listinfo/r-devel >> >> > [[alternative HTML version deleted]] > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel
Specifically: https://svn.r-project.org/R/trunk/src/main/summary.c And if you don't want to deal with Subversion, you can look at the read-only github mirror: https://github.com/wch/r-source/blob/e5b21d0397c607883ff25cca379687b86933d730/src/main/summary.c#L115-L131 On Thu, Feb 21, 2019 at 11:57 AM David Winsemius <dwinsemius at comcast.net> wrote:> > > On 2/20/19 2:55 PM, Rampal Etienne wrote: > > Dear Tomas, > > > > Where do I find these files? Do they contain the code for the sum function? > > Yes. > > https://svn.r-project.org/R/trunk/ > > > David > > > > > What do you mean exactly with your point on long doubles? Where can I find > > documentation on this? > > > > Cheers, Rampal > > > > On Mon, Feb 18, 2019, 15:38 Tomas Kalibera <tomas.kalibera at gmail.com wrote: > > > >> See do_summary() in summary.c, rsum() for doubles. R uses long double > >> type as accumulator on systems where available. > >> > >> Best, > >> Tomas > >> > >> On 2/14/19 2:08 PM, Rampal Etienne wrote: > >>> Hello, > >>> > >>> I am trying to write FORTRAN code to do the same as some R code I > >>> have. I get (small) differences when using the sum function in R. I > >>> know there are numerical routines to improve precision, but I have not > >>> been able to figure out what algorithm R is using. Does anyone know > >>> this? Or where can I find the code for the sum function? > >>> > >>> Regards, > >>> > >>> Rampal Etienne > >>> > >>> ______________________________________________ > >>> R-devel at r-project.org mailing list > >>> https://stat.ethz.ch/mailman/listinfo/r-devel > >> > >> > > [[alternative HTML version deleted]] > > > > ______________________________________________ > > R-devel at r-project.org mailing list > > https://stat.ethz.ch/mailman/listinfo/r-devel > > ______________________________________________ > R-devel at r-project.org mailing list > https://stat.ethz.ch/mailman/listinfo/r-devel