New chachematrix.R file by Sven Willger