From wdunlap at tibco.com  Fri Jul 30 21:58:33 2010
From: wdunlap at tibco.com (William Dunlap)
Date: Fri, 30 Jul 2010 12:58:33 -0700
Subject: [Rd] transpose of complex matrices in R
In-Reply-To: <55722628-0C98-45BC-AFC7-95132F92E2EB@statistik.tu-dortmund.de>
References: <4C529CE0.2070408@cam.ac.uk>
	<55722628-0C98-45BC-AFC7-95132F92E2EB@statistik.tu-dortmund.de>
Message-ID: <77EB52C6DD32BA4D87471DCD70C8D700033E06B0@NA-PA-VBE03.na.tibco.com>

> -----Original Message-----
> From: r-devel-bounces at r-project.org 
> [mailto:r-devel-bounces at r-project.org] On Behalf Of Olaf Mersmann
> Sent: Friday, July 30, 2010 3:01 AM
> To: Robin Hankin
> Cc: R-devel at r-project.org; Martin Maechler
> Subject: Re: [Rd] transpose of complex matrices in R
> 
> Hi,
> 
> On 30.07.2010, at 11:35, Robin Hankin wrote:
> > 3.  Try to define a t.complex() function:
> > t.complex <- function(x){t(Conj(x))}
> > (also fails because of recursion)

The NextMethod() function exists to avoid
this sort of infinite recursion in S3 methods.
E.g.,
   t.complex <- function(x)NextMethod(Conj(x))
or
   t.complex<-function(x)Conj(NextMethod(x))
would do what you wanted.

Using NextMethod means you cannot call this as
   t.complex(nonComplexMatrix)
but I think that is generally a good thing.

Bill Dunlap
Spotfire, TIBCO Software
wdunlap tibco.com 
> 
> Try this version:
> 
>   t.complex <- function(x) {
>     xx <- Conj(x)
>     .Internal(t.default(xx))
>   }
> 
> You get infinite recursion in your example because you keep 
> dispatching on the (complex) result of Conj(x) in t(Conj(x)). 
> I'm not sure if the use of .Internal in user code is 
> sanctioned but it does work for me.
> 
> Cheers,
> Olaf
> 
> ______________________________________________
> R-devel at r-project.org mailing list
> https://stat.ethz.ch/mailman/listinfo/r-devel
> 



[Rd] transpose of complex matrices in R
William Dunlap