Tweaking the SMACOF Engine Jan de Leeuw Version 05, July 19, 2017 Abstract The smacof algorithm for (metric, Euclidean, least squares) multidimensional scaling is rewritten so that all computation is done in C, with only the data management, memory allocation, iteration counting, and I/O handled by R. All symmetric matrices use compact, lower triangular, column-wise storage. Second derivatives of the loss function are provided, but non-metric scaling, individual diļ¬erences, and constraints still have to be added. Contents 1 Introduction 2 2 Implementation 4 3 Timing 4 4 Conclusion 7 5 Appendix: Code 8 5.1 Pure R code .................................... 8 5.1.1 smacofR.R ................................. 8 5.2 R Glue ....................................... 11 5.2.1 smacofRC.R ................................ 11 5.2.2 utilsRC.R ................................. 18 5.2.3 jacobiRC.R ................................ 21 5.2.4 lapackeRC.R ............................... 21 5.3 C code ....................................... 23 5.3.1 smacof.h .................................. 23 5.3.2 smacof.c .................................. 25 5.3.3 utils.c ................................... 31 5.3.4 jacobi.c .................................. 35 5.3.5 lapacke.c .................................. 37 References 38 1