From ripley at stats.ox.ac.uk  Tue Oct 25 14:01:20 2005
From: ripley at stats.ox.ac.uk (Prof Brian Ripley)
Date: Tue, 25 Oct 2005 13:01:20 +0100 (BST)
Subject: [Rd] Small issue with R's C API
In-Reply-To: <435E1A4D.102@DecisionSynergy.com>
References: <435E1A4D.102@DecisionSynergy.com>
Message-ID: <Pine.LNX.4.61.0510251254220.10299@gannet.stats>

This is nothing to do with the C API: isVector and isMatrix are not part 
of the API (see Writing R Extensions for what it is).  That's the `issue' 
here.

On Tue, 25 Oct 2005, Dominick Samperi wrote:

> Consider the R code:
> mat <- matrix(seq(1,20),4,5)
> is.matrix(mat) # gives TRUE
> is.vector(mat) # gives FALSE
>
> On the other hand, if mat is passed through the .Call interface the
> corresponding SEXP (call it smat) satisfies
> isMatrix(smat)   // TRUE
> isVector(smat)  // TRUE
>
> Consequently, you cannot distinguish matrices from vectors. Looking
> at the dim attribute of a vector doesn't help because this is garbage.

You can look to see if it has a dim attribute ... you could also look at 
the C code for is.vector.

Where did you find a definition of isVector?  There is one in the comments 
in src/main/util.c.  It is not as you seem to be assuming a C analogue of
is.vector.

-- 
Brian D. Ripley,                  ripley at stats.ox.ac.uk
Professor of Applied Statistics,  http://www.stats.ox.ac.uk/~ripley/
University of Oxford,             Tel:  +44 1865 272861 (self)
1 South Parks Road,                     +44 1865 272866 (PA)
Oxford OX1 3TG, UK                Fax:  +44 1865 272595



[Rd] Small issue with R's C API
Prof Brian Ripley