Matrix generator