I have created a large positive definite (thus symmetric) matrix in Matlab. For sake of simplicity, let's assume that the matrix has the following form:
$K= \left[ \begin{array}{ccc} k_{11} & \cdots & k_{1n} \\ \vdots & \ddots & \vdots \\ k_{n1} & \cdots & k_{nn}\end{array} \right]$.
Now I want to raise it to a power in an elementwise way, let's say to the power of $\lambda$.
Since $K$ is known, while $\lambda$ is unknown and has to be estimated via an optimization routine, I save beforehand the matrix $K$. In the optimization routine I have to compute at each iteration the value of the matrix raised to the power of $\lambda$.
My question is the following: Is there a way to perform this operation in a fast way, by exploiting the properties of the matrix $K$?
What I have done until now:
1st approach: Compute $K^\lambda$ in a straightforward way, that is to say, using command "K.^\lambda" in matlab.
2nd approach: Use two for loops, where the first one iterates from i=1:n and the second one from j=i:n. This will create an upper diagonal matrix and due to symmetry, I can use triu command to get back the full matrix.
Nonetheless, both approaches are rather time consuming, due to the large size of the matrix. Does anyone have any better idea about how I could perform this operation?
K.^lambda
approach will be faster, because it is vectorized. $\endgroup$