Re: [R] Trace of product of matrices

2014-10-28 Thread Martin Maechler
> Berend Hasselman > on Tue, 28 Oct 2014 11:38:29 +0100 writes: > On 28-10-2014, at 11:05, Martin Maechler wrote: >> …... >> Thank you, Peter, and Spencer. >> >> For a few years now, I have had in my TODO file for the Matrix >> package: >> >> ** TO

Re: [R] Trace of product of matrices

2014-10-28 Thread Berend Hasselman
On 28-10-2014, at 11:05, Martin Maechler wrote: > …... > Thank you, Peter, and Spencer. > > For a few years now, I have had in my TODO file for the Matrix > package: > > ** TODO tr(A %*% B) {and even tr(A %*% B %*% C) ...} are also needed > frequently in some computations {conditional normal

Re: [R] Trace of product of matrices

2014-10-28 Thread Martin Maechler
> peter dalgaard > on Sun, 19 Oct 2014 21:26:39 +0200 writes: >> On 19 Oct 2014, at 19:00 , Spencer Graves wrote: >> >> On 10/19/2014 8:42 AM, peter dalgaard wrote: On 19 Oct 2014, at 16:43 , Wagner Bonat wrote: Dear, I ha

Re: [R] Trace of product of matrices

2014-10-19 Thread peter dalgaard
> On 19 Oct 2014, at 19:00 , Spencer Graves > wrote: > > On 10/19/2014 8:42 AM, peter dalgaard wrote: >>> On 19 Oct 2014, at 16:43 , Wagner Bonat wrote: >>> >>> Dear, >>> >>> I have to compute the trace of a product between four matrices. For >>> example, I know the matrices Wi, Wj and C, I

Re: [R] Trace of product of matrices

2014-10-19 Thread Spencer Graves
On 10/19/2014 8:42 AM, peter dalgaard wrote: On 19 Oct 2014, at 16:43 , Wagner Bonat wrote: Dear, I have to compute the trace of a product between four matrices. For example, I know the matrices Wi, Wj and C, I need to compute this -trace(Wi%*%C^-1%*%Wj%*%C^-1) I would like to avoid compute

Re: [R] Trace of product of matrices

2014-10-19 Thread Spencer Graves
On 10/19/2014 8:42 AM, peter dalgaard wrote: On 19 Oct 2014, at 16:43 , Wagner Bonat wrote: Dear, I have to compute the trace of a product between four matrices. For example, I know the matrices Wi, Wj and C, I need to compute this -trace(Wi%*%C^-1%*%Wj%*%C^-1) I would like to avoid compute

Re: [R] Trace of product of matrices

2014-10-19 Thread peter dalgaard
> On 19 Oct 2014, at 16:43 , Wagner Bonat wrote: > > Dear, > > I have to compute the trace of a product between four matrices. For > example, I know the matrices Wi, Wj and C, I need to compute this > > -trace(Wi%*%C^-1%*%Wj%*%C^-1) > > > I would like to avoid compute the complete matrix and

[R] Trace of product of matrices

2014-10-19 Thread Wagner Bonat
Dear, I have to compute the trace of a product between four matrices. For example, I know the matrices Wi, Wj and C, I need to compute this -trace(Wi%*%C^-1%*%Wj%*%C^-1) I would like to avoid compute the complete matrix and after take the diagonal, something like sum(diag( solve(Wi,C)%*% solve