fix matrix generation

Change-Id: Id31caa16dfe0d0f23cf07589053233e9b311d02f