R functions for fitting latent factor models with internal computation in C/C++