# Sub-portfolio correlation

I am trying to reduce correlation matrices into sub portfolios.

For example, I have a covariance matrix $$\Sigma$$ and weight-vector $$w$$ of two line items which I blend together into a sub-portfolio $$\rho$$, then use $$\sigma(\rho) = \sqrt{w'\Sigma w}$$ to get the sub-portfolio standard deviation. Then to find the correlation between a given asset $$\alpha$$ and the sub-portfolio, I am using $$\frac{cov(\alpha, \rho)}{\sigma(\alpha)\sigma(\rho)}$$ where $$cov(\alpha, \rho) = w_{\alpha}'\Sigma w$$ where $$w_{\alpha}$$ is a vector with a 1 in the entry corresponding to the row of asset $$\alpha$$. I've triple checked my code, and for some reason am continuing to get a correlation above 1. Not sure why this is but any help would be greatly appreciated.