matrixA and matrixB calc