From maechler at stat.math.ethz.ch  Mon May 18 18:04:29 2009
From: maechler at stat.math.ethz.ch (Martin Maechler)
Date: Mon, 18 May 2009 18:04:29 +0200
Subject: [Rd] tcrossprod() inconsistency ?!
Message-ID: <18961.34573.831240.524707@lynne.math.ethz.ch>

The current behavior of  tcrossprod() is not 
consistent with its documentation (*).

crossprod() and tcrossprod() are documented on the same page
(...../base/library/man/crossprod.Rd )

which says {lines broken by me} :

 > Description:

 >      Given matrices 'x' and 'y' as arguments, return a matrix
 >      cross-product.  This is formally equivalent to (but usually
 >      slightly faster than) the call 
 >
 >   't(x) %*% y' ('crossprod')   or
 >   'x %*% t(y)' ('tcrossprod').

and crossprod()  does really work like  t(x) %*% y  in all cases
AFAIK, but  tcrossprod() fails to do so e.g. in

  > m <- matrix(1:6, 2,3) 
  > (1:3) %*% t(m)
       [,1] [,2]
  [1,]   22   28
  > tcrossprod(1:3, m)
  Error in tcrossprod(1:3, m) : non-conformable arguments
  > 

I would like to change tcrossprod() both in 'base' and in 'Matrix'.
Does anyone see reasons why I should not ?
Martin Maechler, ETH Zurich

---
(*) Note that tcrossprod() has been a relatively late addition
    to R, not present in S;  so this inconsistency might seem 
    somewhat excusable.



[Rd] tcrossprod() inconsistency ?!
Martin Maechler