Backport 1.8 3880

Backport #3880. Fixes the linear algebra negative strides problem.

Closes #3876.