Matrix generation.