Fix PC matrix calculation from CD matrix.

This fixes a bug with SWAP files.
Write some broken tests.
Fix CD matrix test and test file
Merge pull request #19 from ayshih/cd

Fix CD matrix test and test file
fix database test numbers
Merge pull request #1145 from Cadair/0.5_cd_matrix_fix

[Review]: Fix PC matrix calculation from CD matrix.