Efficient computation of a product of $3$ matrices. Let $U\in\Bbb{R}^{d\times n}$, such that $U^\top U=I_n$, where $I_k$ denotes the identity matrix of order $k$. Also, let $A\in\Bbb{R}^{n\times n}$ be an $n\times n$ real symmetric matrix. The following product must be computed:
$$
T = UAU^\top\in\Bbb{R}^{d\times d}.
$$
Is there any efficient way for doing so? I am looking for a pseudocode, as I want to implement it in some low-level language ($\texttt{C}$), but without using some linear algebra library (e.g. GLS, etc.). 
Edit:
As an additional comment, let the eigen decomposition of $A$ be known. That is,
$$
A = P\Lambda P^\top,
$$
where $P$ is an $n\times n$ orthonormal matrix consisting of the eigenvectors of $A$, and $\Lambda=\operatorname{diag}(\lambda_1,\ldots,\lambda_n)$ is the $n\times n$ diagonal matrix of the eigenvalues of $A$. Actually, you can assume that $P$ is the matrix created by keeping the first $d$ columns of $U$ followed by transpose operator on it.
Thanks you very much!

Suppose 
$$
\Lambda = \pmatrix{\lambda_1\\&\lambda_2\\&&\ddots\\&&&\lambda_n}
$$
Furthermore, suppose that $P$ is an orthogonal matrix, and that $U$ is the matrix consisting of the first $d$ columns of $P$.  We then have
$$
U^T\Lambda U[i,j] = \sum_{k=1}^n \lambda_k U[k,i] U[k,j] 
$$
