Add fanMatrix and test code