changed handling of case when A->r == 0