Re: [R] code for functions in base package

About this list Date view Thread view Subject view Author view Attachment view

From: Douglas Bates (
Date: Fri 14 May 2004 - 09:40:12 EST

Message-id: <>

> On 13 May 2004 at 16:30, Brittany Erin Laine wrote:
> > Is there any way that I can see the step by step code for functions in
> > the base package? For instance the dexp function. I am a student
> > working on writing my own function for something that is similar to
> > this dexp function and I would like to see the step by step code.
> >
> > Brittany Laine
> > GTA WVU Statistics Department
> > 331 Hodges

As several people have pointed out the dexp function in R immediately
calls .Internal and drops down to C code. For many of the d-p-q
functions like dexp, pexp, and qexp there are short C functions
defined in the src/nmath directory that do the calculation for a
single element of the response vector. The C code that is called
directly by the .Internal is rather complicated but its only purpose
is to provide for the vectorization of the R function. The real
evaluation goes on in dexp.c. In fact, other than checking for error
conditions it amounts to a single statement

    return (give_log ?
            (-x / scale) - log(scale) :
            exp(-x / scale) / scale);

This is all to say that you probably don't want to go through the
step-by-step evaluation of the C code in a symbolic debugger because
most of the code that you will step through is devoted to the
vectorization. Go directly to the corresponding C function in the
src/nmath directory.

______________________________________________ mailing list
PLEASE do read the posting guide!

About this list Date view Thread view Subject view Author view Attachment view

This archive was generated by hypermail 2.1.3 : Mon 31 May 2004 - 23:05:10 EST