[Rcpp-devel] symmatu does not give symmetric matrix

Dirk Eddelbuettel edd at debian.org
Wed Jul 27 14:40:14 CEST 2016


Sorry for the delay in responding.  Mail delivery was stuck at R-Forge for a
few days it seems.

On 21 July 2016 at 10:46, Jendoubi, Takoua wrote:
| Dear all,
| 
| I am using RcppArmadillo to deal with some matrix computations. Specifically I
| need to cholesky factorization of some symmetric matrices.
| 
| I am generating random vectors using Rcpp and using them to construct symmetric
| matrices.
| 
| I have an error stating that my matrix is not symmetric although it definitely
| should be. Here is the example I am working with (in R):
| 
| >x
| [1] -1.6683320 -0.8597148
| >x%*%t(x)
|          [,1]      [,2]
| [1,] 2.783332 1.4342896
| [2,] 1.434290 0.7391095
| 
| Apparently, it is a rounding-off error. Is there any way to ensure that x%*%t
| (x) gives an exactly symmetric matrix to use for cholesky factorization?

I don't know of an automatic way.  R surely has no native type for symmetric
matrices (at least not at the SEXP level as it really only has vectors with
dim attributes).  I would probably start with some helper functions at the R
or C++ level.  Some may have better tricks...

Dirk


-- 
http://dirk.eddelbuettel.com | @eddelbuettel | edd at debian.org


More information about the Rcpp-devel mailing list