[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

Re: [R] Trace and inverse of big matrices

2014-08-28 Thread Wagner Bonat
;- Matrix(0,nrow=nrow,ncol=ncol, sparse = TRUE) ## Restrições de borda R[1,c(1,2)] <- c(1,-1) R[ncol,c(ncol-1,ncol)] <- c(-1,1) ## Corpo da matriz n <- ncol-1 for(i in 2:n){ R[i,c(i-1,i,i+1)] <- c(-1,2,-1)} R <- as(R, "symmetricMatrix") return(R)} 2014-08-25 18:29 G

[R] Trace and inverse of big matrices

2014-08-25 Thread Wagner Bonat
I need to compute two equations related with trace and inverse of a around 3 x 3 density matrices. The equations are -trace( W_i %**% C) and -trace(W_i %**% C %*% W_j C) I know W_i, W_j and inverse of C. These equations are related with Pearson estimating functions. I am trying to use R a

[R] Derivative of expm function

2014-04-23 Thread Wagner Bonat
Hi all ! I am look for some efficient method to compute the derivative of exponential matrix function in R. For example, I have a simple matrix like log.Sigma <- matrix(c(par1, rho, rho, par2),2,2) require(Matrix) Sigma <- expm(log.Sigma) I want some method to compute the derivatives of Sigma

[R] Help - Trace of matrices

2013-12-06 Thread Wagner Bonat
Dear, I need to calculate the following equation tr(Sigma^-1 %*% D.Sigma) I know only Sigma (positive definite) and D.Sigma (derivative of Sigma), a naive code is sum(diag(solve(Sigma,D.Sigma))) but these matrices are dense and big dimension (1 x 1), and I need to evaluate this equatio