avoiding explicit construction of matrix transpose