Optimized linear algebra and R