# [GenABEL-dev] faster polygenic

Yurii Aulchenko yurii.aulchenko at gmail.com
Thu Feb 24 19:13:12 CET 2011

```Some problems with speeding up -- spend last few hours on that, but to no avail.

> see line 23 of 'polylik'
>
> ginvsig <- ervec %*% diag(es,ncol=length(qt)) %*% t(ervec)
>
> this is very stupid way to do this, as time for computations goes
> quadratic because of vector-matrix-vector product -- see example

this is not true -- 'ervec' is a MATRIX (contains eigenvectors of
relashionship matrix). Of cause the fact that in the middle we have
diagonal matrix can be exploited to speed-up a bit, but it still will
be a heavy operation, and quadratic with no. people

> another place where we can gain a bit is probably line 15:
>
> sigma <- h2*tvar*relmat + (1-h2)*tvar*diag(x=1,ncol=nids,nrow=nids)
>
> which is better re-written as
>
> sigma <- h2*tvar*relmat + diag(x=(1-h2)*tvar,ncol=nids,nrow=nids)
>

tried this -- but it does not really help...

what I have figured out as other 'heavy' part is @ line 24

a <- determinant(sigma,logarithm=T)

can we somehow explot the fact that sigma is

sigma <- h2*tvar*relmat + (1-h2)*tvar*diag(x=1,ncol=nids,nrow=nids)

AND we know eigenvalues and eigenvectors (ervec) for relmat?

Any ideas welcome!

Yurii
```