matrix generator class with generating the top elements