> On 04 May 2015, at 19:59 , franknarf <by.hook...@gmail.com> wrote:
> 
> But I'm still wondering why diag() uses c()...? With it being so slow, I'd
> be inclined to write a qdiag() without the c() and just use that the next
> time I need matrix algebra. Any insight would be appreciated; thanks!

Well, there are two possibilities: Either it is deliberate or it isn't. 

The latter isn't too unlikely, given that the effect is seen for large 
matrices. I would appear to be a matter of O(n) (picking out n items) vs. 
O(n^2) (copying an n x n matrix), but this might drown out in a context 
involving matrix multiplication and/or inversion, both of which are O(n^3). 

If it is deliberate, the question is why. There could be devils in the details; 
notice in particular that c() strips off non-name attributes. However, I'm not 
aware of a situation where such attributes could cause trouble.

-pd

-- 
Peter Dalgaard, Professor,
Center for Statistics, Copenhagen Business School
Solbjerg Plads 3, 2000 Frederiksberg, Denmark
Phone: (+45)38153501
Email: pd....@cbs.dk  Priv: pda...@gmail.com

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

Reply via email to