implemeted affine cpd