Normalize matrix