implemented cachematric.R