Changed pinv to classical way. Was getting a seg fault on higher order SH...