Make matrix getters generic