[R] Calculating trace of products
roger koenker
rkoenker at uiuc.edu
Mon Aug 14 14:16:57 CEST 2006
I would suspect that something simple like
sum(diag(crossprod(A,B)))
would be quite competitive...
url: www.econ.uiuc.edu/~roger Roger Koenker
email rkoenker at uiuc.edu Department of Economics
vox: 217-333-4558 University of Illinois
fax: 217-244-6678 Champaign, IL 61820
On Aug 14, 2006, at 6:58 AM, Søren Højsgaard wrote:
> Dear all,
> I need to calculate tr(A B), tr(A B A B) and similar quantities
> **fast** where the matrices A, B are symmetrical. I've searched for
> built-in functions for that purpose, but without luck. Can anyone
> help?
> Thanks in advance
> Søren
>
> [[alternative HTML version deleted]]
>
> ______________________________________________
> R-help at stat.math.ethz.ch mailing list
> https://stat.ethz.ch/mailman/listinfo/r-help
> PLEASE do read the posting guide http://www.R-project.org/posting-
> guide.html
> and provide commented, minimal, self-contained, reproducible code.
More information about the R-help
mailing list