Re: [Rd] loess returns different standard errors for identical models (PR#7956)

2005-06-19 Thread Peter Dalgaard
Peter Dalgaard <[EMAIL PROTECTED]> writes:

> Peter Dalgaard <[EMAIL PROTECTED]> writes:
> 
> > Prof Brian Ripley <[EMAIL PROTECTED]> writes:
> > 
> > > I've seen many similar things in a report from valgrind.  But they
> > > went away when compiled without optimization: it seems optimization
> > > often does a fetch one element off the end of an array when attempting
> > > to keep the pipelines full.
> >  
> > > I'd start by re-running the valgrind tests without optimization.
> > 
> > I was going to anyway, but the reported problem did carry all the
> > hallmarks of the use of a memory location with random content.
> 
> Still present with "-g" recompile, and a breakpoint in lowesb showed
> that the last call had garbage in the "iv" array.

The latter turned out to be a red herring. Apparently a gdb bug messed
up the "x/50d" command that I was using to inspect the array. The real
problem was in other arguments, namely "diagl" and "trl" which are
declared double precision, but passed "&zero" where "zero" is declared
to be of type "Sint".

Now, the 64000$ question is whether it is safe to try and fix it for
2.1.1... 

-- 
   O__   Peter Dalgaard Ă˜ster Farimagsgade 5, Entr.B
  c/ /'_ --- Dept. of Biostatistics PO Box 2099, 1014 Cph. K
 (*) \(*) -- University of Copenhagen   Denmark  Ph: (+45) 35327918
~~ - ([EMAIL PROTECTED])  FAX: (+45) 35327907

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


[Rd] 1-based arrays and copying vectors

2005-06-19 Thread Rob
I'm interfacing to C code that uses 1-based indexing on arrays -- it
ignores the zeroth element.  Thus, input vectors from R must be moved up
one, and output arrays must be moved down one.

What is the best way to deal with this using R internal code?

My current approach is:

For an input R vector of length n, allocate a new vector(v) of length n+1
and copy input into v[1] to v[1+n].  Call with new vector.

For an output array(a) of length n, allocate a new vector of length n-1
and copy a[1] to a[n] into v[0] to v[n-1].

If this is the best approach, is there an idiom for copying vectors?

-Lopaka

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel


Re: [Rd] 1-based arrays and copying vectors

2005-06-19 Thread Douglas Bates
On 6/19/05, Rob Lopaka Lee <[EMAIL PROTECTED]> wrote:
> I'm interfacing to C code that uses 1-based indexing on arrays -- it
> ignores the zeroth element.  Thus, input vectors from R must be moved up
> one, and output arrays must be moved down one.
> 
> What is the best way to deal with this using R internal code?

If the C code can be relied upon to ignore the zero'th element of the
array then write a wrapper that gets the array, say int v[], from R
and passes &v[-1] to your C code.  That has the effect of shifting all
the addresses back by one position.
 
> My current approach is:
> 
> For an input R vector of length n, allocate a new vector(v) of length n+1
> and copy input into v[1] to v[1+n].  Call with new vector.
> 
> For an output array(a) of length n, allocate a new vector of length n-1
> and copy a[1] to a[n] into v[0] to v[n-1].
> 
> If this is the best approach, is there an idiom for copying vectors?

In C you could use the memcpy function or the Memcpy macro defined in
.

__
R-devel@r-project.org mailing list
https://stat.ethz.ch/mailman/listinfo/r-devel