add matrix to indices vice verse