functions for cachable matrix