Skip to content
Back to formatted view

Raw Message

Message-ID: <x2vfs4y3ih.fsf@biostat.ku.dk>
Date: 2003-09-07T18:18:11Z
From: Peter Dalgaard
Subject: bug in crossprod? (PR#4092)
In-Reply-To: <200309071501.h87F10JH001717@pubhealth.ku.dk>

iwhite@staffmail.ed.ac.uk writes:

> # The last line of following code produces a segmentation fault:
> 
> x <- 1:10
> f <- gl(5,2)
> mns <- tapply(x,f,mean)
> crossprod(mns) #to get sum of squares of mns.
> # Of course sum(mns^2) is more straightforward.

Confirmed. Also (and the same thing, I believe)

> z <- array(rnorm(5),5)
> crossprod(z)
         [,1]
[1,] 1.778181
> dimnames(z) <- list(letters[1:5])
> z
         a          b          c          d          e
 0.2810906  0.3457800  0.3663940 -1.1312883  0.4068751
> crossprod(z)

Program received signal SIGSEGV, Segmentation fault.
0x08094d80 in Rf_duplicate (s=0x0) at
../../../R/src/main/duplicate.c:75
75          switch (TYPEOF(s)) {

I suspect the culprit is in the logic starting at line 610 in
src/main/array.c. ("Yes, x and y have dimnames, but not along the
direction we need them"). I can't quite seem to wrap my mind around it
just now though.

-- 
   O__  ---- Peter Dalgaard             Blegdamsvej 3  
  c/ /'_ --- Dept. of Biostatistics     2200 Cph. N   
 (*) \(*) -- University of Copenhagen   Denmark      Ph: (+45) 35327918
~~~~~~~~~~ - (p.dalgaard@biostat.ku.dk)             FAX: (+45) 35327907