[Rd] Registration of native routines

2007-03-01 Thread Gregor Gorjanc
Dear R developers,

I am working on registration of native C and FORTRAN routines and have
encountered "inconsistencies" about this issue. I am referring to
"Registering native routines" section of R-ext manual.

*(DL_FUNC), &F77_SUB, &F77_SYMBOL

On line 5108 of R-ext.texi the array for method myCall is defined as

  {"myCall", &myCall, 3},

but looking at examples in src/library/stats/src/init.c I notice
addition of (DL_FUNC) i.e. upper definition would be

  {"myCall", (DL_FUNC) &myCall, 3},

This probably shows my poor knowledge of C, but what is the role of
(DL_FUNC)? Looking around the code I notice that DL_FUNC is used also in
other places. IMHO I would suggest that (DL_FUNC) is also "mentioned" in
the manual.

Additionally, what is the role of &F77_SUB() in registration of FORTRAN
subroutines i.e. the following line is one example from
src/library/stats/src/init.c.

{"lowesw", (DL_FUNC) &F77_SUB(lowesw), 4}

src/main/registration.c for example uses &F77_SYMBOL() instead of
&F77_SUB(). Poking around the source I see that this is related to _. I
would again suggest to add this to the manual.

*Type and style field

For .C() and .Fortran() manual says that registration array can also
hold type and style fields. It is shown how type field should look like,
but nothing usable is said about style except

Typically, one omits this information in the registration
data.

Why would one omit this if

The purpose is to allow @R{} to transfer values more
efficiently across the R-C/FORTRAN interface by avoiding copying values
when it is not necessary.?

Thank you!

Gregor

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


[Rd] Same method for more than one class

2007-03-01 Thread Gregor Gorjanc
Hi,

when defining method (I used length bellow just for the simplicity) for
myClass (S4 class) I use

setMethod(f="length", signature(x="myClass"),
  def=function(x) {
cat("works")
  })

If I have myClass1 and myClass2 and mentioned method, which is not the
default one, applies to both classes I have to write two setMethod()
statements. Would it be possible to use

signature(x=c("myClass1", "myClass2"))

Currently it issues an error

setClass(Class="myClass1", representation=representation(x="integer"))
setClass(Class="myClass2", representation=representation(x="integer"))
setMethod(f="length", signature(x="myClass1"),
  def=function(x) {
cat("works")
  })
## OK.

setMethod(f="length", signature(x=c("myClass1", "myClass1")),
  def=function(x) {
cat("works")
  })
Error in signature(x = c("myClass1", "myClass1")) :
bad class specified for element 1 (should be a single character string)

Regards, Gregor

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


Re: [Rd] Same method for more than one class

2007-03-01 Thread Sean Davis
On Thursday 01 March 2007 05:47, Gregor Gorjanc wrote:
> Hi,
>
> when defining method (I used length bellow just for the simplicity) for
> myClass (S4 class) I use
>
> setMethod(f="length", signature(x="myClass"),
>   def=function(x) {
> cat("works")
>   })
>
> If I have myClass1 and myClass2 and mentioned method, which is not the
> default one, applies to both classes I have to write two setMethod()
> statements. Would it be possible to use
>
> signature(x=c("myClass1", "myClass2"))

Could you do:

catFun <- function(x) {
  cat("Works")
}
setMethod(f="length", signature(x="myClass1"),def=catFun)
setMethod(f="length", signature(x="myClass2"),def=catFun)

Sean

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


Re: [Rd] Same method for more than one class

2007-03-01 Thread Gregor Gorjanc
Sean Davis wrote:
...
> 
> Could you do:
> 
> catFun <- function(x) {
>   cat("Works")
> }
> setMethod(f="length", signature(x="myClass1"),def=catFun)
> setMethod(f="length", signature(x="myClass2"),def=catFun)

Yep, that is what I wanted.

setMethod(f="length", signature(x=c("myClass1", "myClass2"))

would be shorter, but your proposal is also OK.

Thank you again, Gregor

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


Re: [Rd] Same method for more than one class

2007-03-01 Thread Sean Davis
On Thursday 01 March 2007 06:18, Sean Davis wrote:
> On Thursday 01 March 2007 05:47, Gregor Gorjanc wrote:
> > Hi,
> >
> > when defining method (I used length bellow just for the simplicity) for
> > myClass (S4 class) I use
> >
> > setMethod(f="length", signature(x="myClass"),
> >   def=function(x) {
> > cat("works")
> >   })
> >
> > If I have myClass1 and myClass2 and mentioned method, which is not the
> > default one, applies to both classes I have to write two setMethod()
> > statements. Would it be possible to use
> >
> > signature(x=c("myClass1", "myClass2"))
>
> Could you do:
>
> catFun <- function(x) {
>   cat("Works")
> }
> setMethod(f="length", signature(x="myClass1"),def=catFun)
> setMethod(f="length", signature(x="myClass2"),def=catFun)

That said, it your myclass1 and myclass2 are related, you may want to make 
them both subclasses of a virtual class.  You could then use that virtual 
class in the signature or anywhere you wanted common functionality for two or 
more classes.

Sean

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


Re: [Rd] rgl update: please test!

2007-03-01 Thread laszlo kajan
Hello Duncan,

rgl.snapshot seems ok!

I compiled the source as usual: R CMD INSTALL rgl_0.70.564.tar.gz
on a
Linux hostname 2.6.19-1.2895.fc6 #1 SMP Wed Jan 10 18:50:56 EST 2007 
x86_64 x86_64 x86_64 GNU/Linux

Fedora Core 6.

I tested the rgl.snapshot, and it creates the snapshot png without a hitch.

Best regards,

Laszlo


Duncan Murdoch wrote:
> (This is bcc'd to a list of people who have had problems with rgl lately 
> or who are known to be big users; not cc'd, so you don't all get cc'd 
> all the responses on the R-devel list).
> 
> I've just put together a test build of rgl, and put it on my web site as
> 
> http://www.stats.uwo.ca/faculty/murdoch/software/rgl_0.70.564.tar.gz 
> (source)
> 
> and
> 
> http://www.stats.uwo.ca/faculty/murdoch/software/rgl_0.70.564.zip 
> (Windows binary).
> 
> This includes a number of changes:
> 
>   - changes to configure script from Laszlo Kajan and Brian Ripley: 
> should now be much more portable
>   - removed deprecated OSX font setting calls
>   - texture properties are now returned by material3d()
>   - allowed normals and texture coordinates to be specified in triangles 
> and quads
>   - normals may be specified in qmesh objects, but (at present) 
> subdivide removes them
>   - material3d() now preserves the values of unspecified parameters (as 
> documented, but not previously functioning)
>   - open3d() now resets all material properties to the defaults.
> 
> Could people who have been having problems with rgl (or just making use 
> of it) please test this update?  Some of the changes are very recent, 
> and may still be buggy:  but I'm going offline from late tomorrow until 
> March 4, so I'm not going to have an opportunity to test them myself 
> well enough to want to send this to CRAN.
> 
> I'm hoping to send this to CRAN soon after I return.
> 
> Duncan Murdoch

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