performing a similarity transformation