Calling diag(x)
is apparently very slow. Is there not a faster way to set up a diagonal matrix? It seems like a fairly easy operation, yet R takes forever.
Also, using the diagonal matrix later on in multiplications is also extremely slow. So if I wanted to use sparse matrices, is there a faster way to set up a diagonal sparse matrix?