patmat implementation